<template>
  <div class="page" style="width:99.4%;margin:0 auto;height:auto!important;" v-loading.fullscreen="sendLoading"
    :element-loading-text="operType=='send'?'正在保存并向设备下发配置,请稍等...':'正在保存到后台,请稍等...'"
    element-loading-spinner="el-icon-loading">
    <!-- 展示列表模块 -->
    <div class="top" style="width:100%!important;">
      <div style="float:left;"><span @click="goList" class="goback">设备管理</span> | <span class="goback"
          @click="goBack">网关配置</span> | <span>读取配置</span> |
        <span>{{deviceData.equip_name}}(编码：{{deviceData.equip_code}}<span
            v-if="deviceData.firmware_version">　固件版本：{{'V'+deviceData.firmware_version}}</span>)</span></div>
      <!-- <div class="tip_2">特别提示：读取并保存配置后,组态数据点需要重新绑定,请慎重操作！</div> -->
      <el-button type="primary" size="small" id="goback" @click="goBack">返回</el-button>
      <!-- <el-button type="primary" size="small" id="goback" style="margin-right:0.3rem;" @click="goData">监控</el-button> -->
      <el-button type="primary" size="small" id="goback" style="margin-right:0.3rem;" v-if="channelSlaves.length"
        @click="saveSet('save')">保存
      </el-button>
      <el-button v-if="channelSlaves.length" type="primary" size="small" id="goback"
        style="width:auto;margin-right:0.1rem;padding-left:0.2rem;padding-right:0.2rem;" :disabled="canSet"
        @click="saveSet('send')">保存并下发
      </el-button>
      <el-button type="primary" size="small" id="goback" style="margin-right:0.1rem;" :disabled="canSet"
        @click="repeatRead()">重新读取
      </el-button>
    </div>
    <!-- 左侧端口配置 -->
    <div class="channel" ref="channel">
      <span class="channelBack" @click="hiddenChannel" v-if="showChannel"><i class="el-icon-back"></i></span>
      <div class="header_bottom" v-if="channelSlaves.length">
        <!-- 用于暂不支持多端口，临时禁用此添加-->
        <!-- <el-button size="small" type="success" @click="preAddChannel">添加新端口</el-button> -->
        <el-button size="mini" type="primary" style="padding:8px;" @click="preAddSlave">添加子设备</el-button>
        <!-- <el-button size="small"  type="primary"  @click="getChannel">刷新端口</el-button> -->
      </div>
      <el-tree v-if="channelSlaves.length" style="width:100%;font-size:0.3rem;text-align:justify;" ref="tree"
        :data="channelSlaves" node-key="id" default-expand-all :expand-on-click-node="false" :indent="14">
        <span slot-scope="{ node, data }" class="custom-tree-node" :class="node.level==1?'channel_sign':''"
          @click="() => getInfo(node,data)">
          <span v-if="node.level==1">端口{{data.index}}：{{channelToUpper(node.label)}}</span>
          <span v-else><i class="el-icon-s-tools" style="color:deepskyblue;"></i>:{{ node.label }}</span>
          <span>
            <i style="font-size:0.4rem;color:#409Eff;" class="el-icon-edit-outline" @click="() => edit(node,data)">
            </i>
            <i v-if="node.level==2" style="font-size:0.4rem;color:#f56c6c;" class="el-icon-delete"
              @click="() => remove(node, data)">
            </i>
          </span>
        </span>
      </el-tree>
      <!-- 端口详情展示区 -->
      <div class="infobox" v-if="infoShow=='channel' && channelInfo.channel_type">
        <ChannelInfo :channelInfo="channelInfo" :channelTip="channelTip" />
      </div>
      <div class="infobox" v-if="infoShow=='channel' && (!channelInfo.channel_type)"
        style="font-size:0.3rem;color:#bbb;">
        暂无数据
      </div>
      <!-- 子设备详情展示区 -->
      <div class="infobox" v-if="infoShow=='slave' && slaveInfo.slave_protocol">
        <SlaveInfo :slaveInfo="slaveInfo" :slaveTip="slaveTip" :styleObj="styleObj" />
      </div>
    </div>
    <!-- 中隔线 -->
    <div class="midLine" v-if="showChannel"></div>
    <!-- 右侧子设备配置 -->
    <div class="slave" ref="slave" id="slaveBox" v-show="slaveSensorData.length" @scroll="changeScroll"
      v-loading.fullscreen="loading" element-loading-text="正在读取中..." element-loading-spinner="el-icon-loading">
      <span class="channelShow" @click="hiddenChannel" v-if="!showChannel"><i class="el-icon-right"></i></span>
      <div id="topMao" style="width:0;height:0;"></div>
      <span class="toBottom" v-if="showMao=='goBottom'" @click="returnBottom"><i class="el-icon-bottom"
          style="color:#fff;font-size:0.5rem;vertical-align:middle;"></i></span>
      <!-- <div v-for="item in slaveSensorData" :key="item.slave_no" :id="item.slave_name" style="height:auto;">
			<div style="width:99.4%;border-bottom:1px solid deepskyblue;position:relative;" @click="openClose($event)"> -->
      <div v-for="item in slaveSensorData" :key="item.slave_no" :id="item.slave_name">
        <div style="width:99.4%;border-bottom:1px solid deepskyblue;position:relative;">
          <div class="btnBox">
            <!-- <i class="el-icon-caret-right" style="color:deepskyblue;font-size:0.5rem;vertical-align:middle;"></i> -->
            <span class="slavePoint"></span>
            <div style="display:inline-block;color:#fff">子设备名称:{{item.slave_name}}</div>
            <el-button @click="addSensors(item)" type="primary" size="mini" class="addSensor">新增数据点
            </el-button>
            <el-button @click="preModifySlave(item)" type="primary" size="mini" class="addSensor"
              style="margin-right:0.2rem;">编辑子设备</el-button>

          </div>
          <i class="el-icon-caret-top"
            style="position:absolute;right:-5px;bottom:-10px;font-size:30px;color:deepskyblue;"></i>
        </div>
        <div class="sensorBox" id="sensorOne">
          <div class="sensorHead" style="width:99.4%;white-space: nowrap;" ref="sensorHead">
            <span class="inpu_4" style="width:0.8rem;height:0.8rem;margin-left: 0;">图标</span>
            <!-- <div class="inpu_4" style="width:4rem;"><span>名称</span><span class="sortIcon"><i class="el-icon-caret-bottom" @click="sortSensorNameDown"></i></span><span class="sortIcon"><i class="el-icon-caret-top" @click="sortSensorNameUp"></i></span></div> -->
            <!-- <div class="inpu_4" style="width:2rem;"><span>地址</span><span class="sortIcon"><i class="el-icon-caret-bottom" @click="sortSensorKeyDown"></i></span><span class="sortIcon"><i class="el-icon-caret-top" @click="sortSensorKeyUp"></i></span></div> -->
            <!-- <div class="inpu_4" style="width:2rem;"><span>数据属性</span><span class="sortIcon"><i class="el-icon-caret-bottom" @click="sortSensorTypeDown"></i></span><span class="sortIcon"><i class="el-icon-caret-top" @click="sortSensorTypeUp"></i></span></div> -->
            <span class="inpu_4" style="width:3.9rem;">名称</span>
            <span class="inpu_4" style="width:2rem;color:deepskyblue;">地址</span>
            <span class="inpu_4" style="width:3.9rem;color:deepskyblue;">键名</span>
            <span class="inpu_4" style="width:2.6rem;color:deepskyblue;">数值类型</span>
            <span class="inpu_4" style="width:1.1rem;color:deepskyblue;">倍数</span>
            <span class="inpu_4" style="width:1.2rem;color:deepskyblue;">偏置</span>
            <!-- <span class="inpu_4" style="width:1.6rem" v-show="more">小数位</span> -->
            <span class="inpu_4" style="width:1.3rem;color:deepskyblue;">小数位</span>
            <span class="inpu_4" style="width:1.2rem;color:deepskyblue;">阈值</span>
            <!-- <span v-if="deviceData.app_scene==2" class="inpu_4" style="width:1.8rem;color:deepskyblue;">低限</span>
				        <span v-if="deviceData.app_scene==2" class="inpu_4" style="width:1.8rem;color:deepskyblue;">高限</span>
				        <span v-if="deviceData.app_scene==2" class="inpu_4" style="width:1.8rem;color:deepskyblue;">标记</span> -->
            <span class="inpu_4" v-if="deviceData.app_scene==2" style="width:1.8rem;color:deepskyblue;">低限</span>
            <!-- <span class="inpu_4" v-else style="width:1.8rem;">低限</span> -->
            <span class="inpu_4" v-if="deviceData.app_scene==2" style="width:1.8rem;color:deepskyblue;">高限</span>
            <!-- <span class="inpu_4" v-else style="width:1.8rem;">高限</span> -->
            <span v-if="deviceData.app_scene==2" class="inpu_4" style="width:1.8rem;color:deepskyblue;">标记</span>
            <span class="inpu_4" style="width:2.6rem;color:deepskyblue;">数据属性</span>
            <!-- <div class="inpu_4" style="width:1.8rem;" v-show="more"> -->
            <div class="inpu_4" style="width:1.8rem;">
              <span>单位</span>
              <el-tooltip placement="top" effect="light">
                <div slot="content" style="line-height:0.4rem;color:red;">
                  注意事项:<br />为了体现专业化和减少占位长度以方便显示，尤其是手机端的显示，单位请使用数学写法，勿使用汉字！</div>
                <span class="sortIcon" style="color:red;">!</span>
              </el-tooltip>
            </div>
            <span class="inpu_4" style="width:2.6rem;">读写/显示</span>
            <!-- <span class="inpu_4" style="width:2rem;">存储</span> -->
            <div class="inpu_4" style="width:2rem;">
              <span>存储</span>
              <el-tooltip placement="top" effect="light">
                <div slot="content" style="line-height:0.4rem;color:red;">注意事项:<br />如果选择不存储，该数据点将没有历史数据和历史曲线！</div>
                <span class="sortIcon" style="color:red;">!</span>
              </el-tooltip>
            </div>
            <div class="inpu_4" style="width:1.2rem;">
              <span>排序</span>
              <el-tooltip placement="top" effect="light">
                <div slot="content" style="line-height:0.4rem;">
                  支持的排序写法:<br />1.数字:如:0,1,2,3,...;<br />2.小写字母+数字:如:a1,a2,a3,...,b1,b2,b3,...</div>
                <span class="sortIcon">?</span>
              </el-tooltip>
            </div>
            <span class="inpu_4" style="width:2.3rem">操作</span>
          </div>
          <div v-if="item.sensors.length" style="width:99.4%;white-space: nowrap;overflow:visible;">
            <div v-for="(sensor,i) in item.sensors" :key="i" class="oneSensor">
              <img :src="sensor.icon?baseurl+sensor.icon:baseurl+'static/images/icon/icon1.png'"
                style="width:0.7rem;height:0.7rem;margin-top:1px;" />
              <span class="inpu_2 over" style="width:4rem;position:relative;">{{sensor.sensor_name}}</span>
              <span class="inpu_2" style="width:2rem;">{{sensor.data_key}}</span>
              <span class="inpu_2" style="width:4rem;">{{sensor.value_key}}</span>
              <span class="inpu_2" style="width:2.6rem;">{{sensor.value_type | valueTypeFilter(sensor.data_key)}}</span>
              <span class="inpu_2" style="width:1.2rem;">{{sensor.magnification}}</span>
              <span class="inpu_2" style="width:1.2rem;">{{sensor.value_offset}}</span>
              <!-- <span class="inpu_2" style="width:1.5rem" v-show="more">{{item.decimals}}</span> -->
              <span class="inpu_2" style="width:1.2rem">{{sensor.decimals}}</span>
              <span class="inpu_2" style="width:1.2rem;">{{sensor.threshold}}</span>
              <!-- <span v-if="deviceData.app_scene==2" class="inpu_2" style="width:1.8rem;">{{sensor.min_value}}</span>
					        <span v-if="deviceData.app_scene==2" class="inpu_2" style="width:1.8rem;">{{sensor.max_value}}</span>
					        <span v-if="deviceData.app_scene==2" class="inpu_2" style="width:1.8rem;">{{sensor.mark | waterMark}}</span> -->
              <span v-if="deviceData.app_scene==2" class="inpu_2" style="width:1.8rem;">{{sensor.min_value}}</span>
              <span v-if="deviceData.app_scene==2" class="inpu_2" style="width:1.8rem;">{{sensor.max_value}}</span>
              <span v-if="deviceData.app_scene==2" class="inpu_2"
                style="width:1.8rem;">{{sensor.mark | waterMark}}</span>
              <span class="inpu_2" style="width:2.6rem">{{sensor.report_type | reportTypeFilter}}</span>
              <!-- <span class="inpu_2" style="width:1.8rem" v-show="more">{{item.unit}}</span> -->
              <span class="inpu_2" style="width:1.8rem">{{sensor.unit}}</span>
              <span class="inpu_2" style="width:2.6rem;">{{sensor.show_type | showTypeFilter}}</span>
              <!-- <span class="inpu_2" style="width:2rem;">{{item.read_write}}</span> -->
              <span class="inpu_2" style="width:2rem;">{{sensor.save_type}}</span>
              <!-- <span class="inpu_2 over" style="width:3.5rem" :title="item.ext_vars" v-show="more">{{item.ext_vars}}</span> -->
              <!-- <span class="inpu_2" style="width:1.2rem;" v-show="more">{{item.list_order}}</span> -->
              <span class="inpu_2" style="width:1.2rem;">{{sensor.list_order}}</span>
              <el-button @click.prevent="sureDeleteSensor(sensor,i,$event)" type="danger" size="mini"
                style="transform: translate(0.1rem,-0.28rem);padding:6px 10px;" class="btn_1600">删除</el-button>
              <el-button @click.prevent="showUpdate(sensor,i,$event)" type="primary" size="mini"
                style="transform: translate(-0.1rem,-0.28rem);padding:6px 10px;" class="btn_1600">编辑</el-button>
              <!-- <el-button @click.prevent="copyMore(sensor,$event)" type="primary" size="mini" style="transform: translate(-0.1rem,-0.32rem);">复制</el-button> -->

            </div>

          </div>
          <div v-else class="oneSensor" style="font-size:0.3rem;color:#aaa;text-align:center;">
            <p>{{deviceData.app_scene==3?'该子设备暂无数据点':'该子设备暂无数据点，你可以现在添加，或在编辑子设备时使用数据点模板！'}}</p>
          </div>
        </div>
      </div>
      <span class="toTop" v-if="showMao=='goTop'" @click="returnTop"><i class="el-icon-top"
          style="color:#fff;font-size:0.5rem;vertical-align:middle;"></i></span>
      <div id="bottomMao" style="width:0;height:0;"></div>

      <el-dialog :visible.sync="dialogFormVisible" v-el-dialog-drag v-el-dialog-drag-width
        :width="screenWidth>1600?'60%':'70%'" append-to-body :show-close="close" :close-on-click-modal="false"
        top="60px" class="dial">
        <div class="toptit">
          <span>新增数据点</span>
          <span style="float:right;cursor: pointer;" @click="cancelAdd">关闭</span>
        </div>
        <el-form :model="addForm" style="text-align: left;" inline>
          <div class="slaveInfo_3">
            <span style="font-size:0.3rem;font-weight: 600;">从属信息：</span>
            <span>当前端口：{{channelToUpper(addForm.channel_type)}}</span>
            <span style="margin-left:0.4rem;">当前子设备：<span style="color:red;">{{addForm.slave_name}}</span></span>
            <span style="margin-left:0.4rem;">当前协议：{{protocolToUpper(addForm.slave_protocol)}}</span>
          </div>
          <div v-if="addForm.slave_protocol.indexOf('645')<=0" class="slaveInfo_3"
            style="height:1.4rem;padding-top:0.1rem;display:inline-block;vertical-align: middle;">
            <span style="font-size:0.3rem;font-weight: 600;">批量选项：</span>
            <el-form-item label="数据通道:">
              <el-select v-model="addForm.data_channel" class="inpu_3"
                @change="changeDataChannel(addForm.data_channel,'changeChannel')">
                <el-option v-for="item in dataChannels" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item class="equipArg" label="DB块号:"
              v-if="addForm.data_channel=='D' && addForm.slave_protocol.indexOf('_fx_')<0">
              <el-input class="inpu_5" v-model="addForm.boxNum" placeholder=""
                @input="createFirstKey(addForm.slave_protocol,addForm.data_channel,addForm.value_type,addForm.first_key,addForm.boxNum)"></el-input>
            </el-form-item>
            <el-form-item label="起始地址:">
              <el-input class="inpu_5" v-model="addForm.first_key"
                @input="createFirstKey(addForm.slave_protocol,addForm.data_channel,addForm.value_type,addForm.first_key,addForm.boxNum)"
                placeholder=""></el-input>
            </el-form-item>
            <el-form-item class="equipArg" label="数值类型:">
              <el-select v-model="addForm.value_type" class="inpu_3" @change="changeValueType(addForm.value_type)"
                style="width:3rem;">
                <el-option v-for="item in valueTypes" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="数量:">
              <el-input class="inpu_5" v-model="addForm.sensor_total" placeholder=""></el-input>
            </el-form-item>
          </div>
          <div v-else class="slaveInfo_3"
            style="height:1.8rem;padding-top:0.1rem;display:inline-block;vertical-align: middle;">
            <!-- <span style="font-size:0.3rem;font-weight: 600;">批量选项：</span> -->
            <el-form-item label="标识DI3:" v-if="addForm.slave_protocol.indexOf('2007')>=0">
              <el-input class="inpu_5" v-model="addForm.sign_3" placeholder="标识DI3" @input="createT645Key()"></el-input>
            </el-form-item>
            <el-form-item label="标识DI2:" v-if="addForm.slave_protocol.indexOf('2007')>=0">
              <el-input class="inpu_5" v-model="addForm.sign_2" placeholder="标识DI2" @input="createT645Key()"></el-input>
            </el-form-item>
            <el-form-item label="标识DI1:">
              <el-input class="inpu_5" v-model="addForm.sign_1" placeholder="标识DI1" @input="createT645Key()"></el-input>
            </el-form-item>
            <el-form-item label="标识DI0:">
              <el-input class="inpu_5" v-model="addForm.sign_0" placeholder="标识DI0" @input="createT645Key()"></el-input>
            </el-form-item>
            <el-form-item class="equipArg" label="数值类型:">
              <el-select v-model="addForm.value_type" placeholder="数值类型:" class="inpu_3" style="width:3rem;">
                <el-option v-for="item in valueTypes_T645" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="" style="margin-top:-0.3rem;">
              <span class="tip" style="width:100%;color:red;margin-top:0;">注:1.标识必须是00至FF的16进制写法;2.当前协议不支持批量添加;</span>
            </el-form-item>
          </div>
          <el-form-item class="formline_2" style="width:100%;">
            <div style="font-size:0.3rem;font-weight: 600;width:100%;">数据点参数：<span
                style="color:red;">已默认部分参数，排序会自动追加</span></div>
          </el-form-item>
          <!-- <el-form-item label="名称:" class="formline_2" :label-width="formLabelWidth2">
						<el-input class="inpu_3 over" v-model="addForm.sensor_name" placeholder="数据点名称"></el-input>
					</el-form-item> -->
          <el-form-item label="地址:" class="formline_2 equipArg" :label-width="formLabelWidth2">
            <el-input class="inpu_3" v-model="addForm.data_key" placeholder="数据地址"></el-input>
          </el-form-item>
          <el-form-item label="键名:" class="formline_2 equipArg" :label-width="formLabelWidth2">
            <el-input class="inpu_3" v-model="addForm.value_key" placeholder="数据键名"></el-input>
          </el-form-item>
          <el-form-item class="formline_2 equipArg" label="倍数:" :label-width="formLabelWidth2">
            <el-input class="inpu_3" v-model="addForm.magnification" placeholder="输入倍数"
              @input="changeMinMax(addForm.value_type,addForm.magnification,addForm.threshold)"></el-input>
          </el-form-item>
          <el-form-item class="formline_2 equipArg" label="偏置:" :label-width="formLabelWidth2">
            <el-input class="inpu_3" v-model="addForm.value_offset" placeholder="输入偏置"></el-input>
          </el-form-item>
          <el-form-item class="formline_2 equipArg" label="小数位:" :label-width="formLabelWidth2">
            <el-select :disabled="addForm.show_type>2" v-model="addForm.decimals" class="inpu_3"
              @change="changeAddDecimal(addForm.decimals,addForm.magnification)">
              <el-option v-for="item in points" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="formline_2 equipArg" label="阈值:" :label-width="formLabelWidth2">
            <el-input class="inpu_3" v-model="addForm.threshold" placeholder="输入阈值"
              @input="changeMinMax(addForm.value_type,addForm.magnification,addForm.threshold)"></el-input>
          </el-form-item>
          <!-- <el-form-item v-show="deviceData.app_scene==2"  class="formline_2 equipArg" label="低限:" :label-width="formLabelWidth2">
						<el-input class="inpu_3" v-model="addForm.min_value" placeholder="输入低限值"></el-input>
					</el-form-item>
					<el-form-item v-show="deviceData.app_scene==2"  class="formline_2 equipArg" label="高限:" :label-width="formLabelWidth2">
						<el-input class="inpu_3" v-model="addForm.max_value" placeholder="输入高限值"></el-input>
					</el-form-item>
					<el-form-item v-show="deviceData.app_scene==2"  class="formline_2 equipArg" label="标记:" :label-width="formLabelWidth2">
						<el-select v-model="addForm.mark" class="inpu_3" >
							<el-option v-for="item in waterMarks" :key="item.value" :value="item.value" :label="item.label">
							</el-option>
						</el-select>
					</el-form-item> -->
          <el-form-item v-show="deviceData.app_scene==2" class="formline_2 equipArg" label="低限:"
            :label-width="formLabelWidth2">
            <el-input class="inpu_3" v-model="addForm.min_value" placeholder="输入低限值"></el-input>
          </el-form-item>
          <el-form-item v-show="deviceData.app_scene==2" class="formline_2 equipArg" label="高限:"
            :label-width="formLabelWidth2">
            <el-input class="inpu_3" v-model="addForm.max_value" placeholder="输入高限值"></el-input>
          </el-form-item>
          <el-form-item v-show="deviceData.app_scene==2" class="formline_2 equipArg" label="标记:"
            :label-width="formLabelWidth2">
            <el-select v-model="addForm.mark" class="inpu_3">
              <el-option v-for="item in waterMarks" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="formline_2 equipArg" label="数据属性:" :label-width="formLabelWidth2">
            <el-select v-model="addForm.report_type" class="inpu_3">
              <el-option v-for="item in reportTypes" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="formline_2" label="读写/显示:" :label-width="formLabelWidth2">
            <el-select v-model="addForm.show_type" placeholder="读写/显示:" class="inpu_3"
              @change="changeAddType(addForm.show_type)">
              <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="formline_2" label="单位:" :label-width="formLabelWidth2">
            <el-input :disabled="addForm.show_type>2" class="inpu_3" v-model="addForm.unit"
              :placeholder="addForm.show_type<3?'单位，可为空':'非数值，禁用'"></el-input>
          </el-form-item>
          <el-form-item class="formline_2" label="数据存储:" :label-width="formLabelWidth2">
            <el-select v-model="addForm.save_type" placeholder="是否存储" class="inpu_3">
              <el-option v-for="item in saves" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="formline_2" label="排序:" :label-width="formLabelWidth2">
            <el-input class="inpu_3" v-model="addForm.list_order" placeholder="排序"></el-input>
          </el-form-item>
          <el-form-item class="formline_2" style="height:1rem;line-height:1rem;margin-top:0.1rem;" label="图标:"
            :label-width="formLabelWidth2">
            <!-- <el-popover placement="top" width="240"
							style="height:3.5rem;line-height:1rem;vertical-align: middle;margin-top:-0.5rem;margin-left:0.1rem;"
							trigger="manual" v-model="addForm.visible"> -->
            <el-popover placement="top" width="240"
              style="height:3.5rem;line-height:1rem;vertical-align: middle;margin-top:-0.5rem;margin-left:0.1rem;"
              trigger="click">
              <img v-for="(i) in 18" :key="i" :src="baseurl+'static/images/icon/icon'+i+'.png'" class="thumb"
                style="margin-left:0.27rem;margin-bottom: 0.2rem;" :id="i" @click="chooseIcon" />
              <!-- <el-button slot="reference" class="iconbtn" @click="addForm.visible = true"><img
									:src="baseurl+addForm.icon" class="thumb" /></el-button> -->
              <el-button slot="reference" class="iconbtn">
                <img :src="baseurl+addForm.icon" class="thumb" />
              </el-button>
            </el-popover>
            <span style="float:right;width:auto;vertical-align: middle;margin:0.1rem 0.2rem;">点击图标切换</span>
          </el-form-item>
        </el-form>
        <div style="text-align: right;margin-top:0.2rem;">
          <el-button size="small" @click="cancelAdd">取 消</el-button>
          <el-button type="primary" size="small" @click="addHappen(addForm.slave_name)">确 定</el-button>
        </div>
      </el-dialog>
      <el-dialog :visible="dialogFormVisible_2" v-el-dialog-drag v-el-dialog-drag-width
        :width="screenWidth>1600?'50%':'60%'" append-to-body :show-close="close" :close-on-click-modal="false"
        top="60px" class="dial">
        <div class="toptit">
          <span>编辑数据点</span>
          <span style="float:right;cursor: pointer;" @click="cancelUpdate">关闭</span>
        </div>
        <el-form :model="editForm" style="text-align:left;" inline>
          <div class="slaveInfo_3">
            <span style="font-size:0.3rem;font-weight: 600;">从属信息：</span>
            <span>当前端口：{{channelToUpper(editForm.channel_type)}}</span>
            <span style="margin-left:0.4rem;">当前子设备：<span style="color:red;">{{editForm.slave_name}}</span></span>
            <span style="margin-left:0.4rem;">当前协议：{{protocolToUpper(editForm.slave_protocol)}}</span>
          </div>
          <el-form-item label="名称:" class="formline_2" style="width:100%;margin:0.1rem 0;"
            :label-width="formLabelWidth2">
            <el-input class="inpu_3 over" style="vertical-align: middle;" v-model="editForm.sensor_name"
              placeholder="数据点名称"></el-input><span class="tip"
              style="display:inline-block;width:auto;vertical-align: middle;margin-left:0.2rem;">名称和地址必须唯一,名称用于显示和选择,地址用于数据传输,排序决定显示顺序</span>
          </el-form-item>
          <!-- <el-form-item label="名称:" class="formline_2" style="margin-top:0.1rem;" :label-width="formLabelWidth2">
						<el-input class="inpu_3 over" style="vertical-align: middle;" v-model="editForm.sensor_name" placeholder="数据点名称"></el-input>
					</el-form-item> -->

          <el-form-item label="地址:" class="formline_2 equipArg" :label-width="formLabelWidth2">
            <el-input class="inpu_3" v-model="editForm.data_key" placeholder="数据地址" disabled></el-input>
          </el-form-item>
          <el-form-item label="键名:" class="formline_2 equipArg" :label-width="formLabelWidth2">
            <el-input class="inpu_3" v-model="editForm.value_key" placeholder="数据键名"></el-input>
          </el-form-item>
          <el-form-item class="formline_2 equipArg" label="数值类型:" :label-width="formLabelWidth2">
            <el-select v-model="editForm.value_type" placeholder="数值类型:" class="inpu_3" disabled>
              <el-option v-for="item in valueTypes" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="formline_2 equipArg" label="倍数:" :label-width="formLabelWidth2">
            <el-input class="inpu_3" v-model="editForm.magnification" placeholder="输入倍数"
              @input="changeEditMinMax(editForm.value_type,editForm.magnification,editForm.threshold)"></el-input>
          </el-form-item>
          <el-form-item class="formline_2 equipArg" label="偏置:" :label-width="formLabelWidth2">
            <el-input class="inpu_3" v-model="editForm.value_offset" placeholder="输入偏置"></el-input>
          </el-form-item>
          <el-form-item class="formline_2 equipArg" label="阈值:" :label-width="formLabelWidth2">
            <el-input class="inpu_3" v-model="editForm.threshold" placeholder="输入阈值"
              @input="changeEditMinMax(editForm.value_type,editForm.magnification,editForm.threshold)"></el-input>
          </el-form-item>
          <el-form-item class="formline_2 equipArg" label="小数位:" :label-width="formLabelWidth2">
            <el-select :disabled="editForm.show_type>2" v-model="editForm.decimals"
              @change="changeEditDecimal(editForm.decimals,editForm.magnification)"
              :placeholder="editForm.show_type>2?'非数值,禁用':''" class="inpu_3">
              <el-option v-for="item in points" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <!-- <el-form-item v-show="deviceData.app_scene==2"  class="formline_2 equipArg" label="低限:" :label-width="formLabelWidth2">
						<el-input class="inpu_3" v-model="editForm.min_value" placeholder="输入低限值"></el-input>
					</el-form-item>
					<el-form-item v-show="deviceData.app_scene==2"  class="formline_2 equipArg" label="高限:" :label-width="formLabelWidth2">
						<el-input class="inpu_3" v-model="editForm.max_value" placeholder="输入高限值"></el-input>
					</el-form-item>
					<el-form-item v-show="deviceData.app_scene==2"  class="formline_2 equipArg" label="标记:" :label-width="formLabelWidth2">
						<el-select v-model="editForm.mark" class="inpu_3" >
							<el-option v-for="item in waterMarks" :key="item.value" :value="item.value" :label="item.label">
							</el-option>
						</el-select>
					</el-form-item> -->
          <el-form-item v-show="deviceData.app_scene==2" class="formline_2 equipArg" label="低限:"
            :label-width="formLabelWidth2">
            <el-input class="inpu_3" v-model="editForm.min_value" placeholder="输入低限值"></el-input>
          </el-form-item>
          <el-form-item v-show="deviceData.app_scene==2" class="formline_2 equipArg" label="高限:"
            :label-width="formLabelWidth2">
            <el-input class="inpu_3" v-model="editForm.max_value" placeholder="输入高限值"></el-input>
          </el-form-item>
          <el-form-item v-show="deviceData.app_scene==2" class="formline_2 equipArg" label="标记:"
            :label-width="formLabelWidth2">
            <el-select v-model="editForm.mark" class="inpu_3">
              <el-option v-for="item in waterMarks" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="formline_2 equipArg" label="数据属性:" :label-width="formLabelWidth2">
            <el-select v-model="editForm.report_type" class="inpu_3">
              <el-option v-for="item in reportTypes" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="formline_2" label="读写/显示:" style="margin-top:0.1rem;" :label-width="formLabelWidth2">
            <el-select v-model="editForm.show_type" placeholder="读写/显示:" class="inpu_3"
              @change="changeEditType(editForm.show_type)">
              <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="formline_2" label="数据存储:" :label-width="formLabelWidth2">
            <el-select v-model="editForm.save_type" placeholder="是否存储" class="inpu_3">
              <el-option v-for="item in saves" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="formline_2" label="单位:" :label-width="formLabelWidth2">
            <el-input :disabled="editForm.show_type>2" class="inpu_3" v-model="editForm.unit"
              :placeholder="editForm.show_type>2?'非数值,禁用':'单位,可无'"></el-input>
          </el-form-item>
          <el-form-item class="formline_2" label="排序:" :label-width="formLabelWidth2">
            <el-input class="inpu_3" v-model="editForm.list_order" placeholder="排序"></el-input>
          </el-form-item>
          <el-form-item class="formline_2" style="height:1rem;line-height:1rem;margin-top:0.1rem;" label="图标:"
            :label-width="formLabelWidth2">
            <el-popover placement="top" width="240"
              style="height:3.5rem;line-height:1rem;vertical-align: middle;margin-top:-0.5rem;margin-left:0.1rem;"
              trigger="click">
              <img v-for="(i) in 18" :key="i" :src="baseurl+'static/images/icon/icon'+i+'.png'" class="thumb"
                style="margin-left:0.27rem;margin-bottom: 0.2rem;" :id="i" @click="chooseIcon_2" />
              <el-button slot="reference" class="iconbtn"><img :src="baseurl+editForm.icon" class="thumb" /></el-button>
            </el-popover>
            <span style="float:right;width:auto;vertical-align: middle;margin:0.1rem 0.2rem;">点击图标切换</span>
          </el-form-item>
        </el-form>
        <div style="text-align: right;margin-top:0.4rem;">
          <el-button size="small" @click="cancelUpdate">取 消</el-button>
          <el-button type="primary" size="small" @click="updateHappen">确 定</el-button>
        </div>
      </el-dialog>
    </div>
    <div v-show="!slaveSensorData.length" class="slave" style="color:#bbb;font-size:0.3rem;"
      v-loading.fullscreen="loading" element-loading-text="正在读取中..." element-loading-spinner="el-icon-loading">
      暂无数据
    </div>
    <el-dialog :visible.sync="editFormVisible" v-el-dialog-drag v-el-dialog-drag-width width="26%" id="smallScreen"
      append-to-body :show-close="close" top="100px" class="dial">
      <div class="toptit">
        <span>编辑端口</span>
        <span style="float:right;cursor: pointer;" @click="editFormVisible = false">关闭</span>
      </div>
      <!-- 将下面内容放到添加对话框中 -->
      <div class="channelHead" style="max-height:2.2rem;line-height:1rem;">
        <span class="choice"
          style="width:2.1rem;text-indent:0;margin-left:1rem;text-align:right;">端口名称:</span><span>{{channelToUpper(editChannelForm.channel_type)}}</span><br>
        <span v-show="deviceData.version==3" class="choice"
          style="width:2.1rem;text-align:right;">运行模式:&nbsp;&nbsp;</span>
        <el-select v-show="deviceData.version==3" v-model="editChannelForm.channel_mode" placeholder="选择运行模式"
          class="slaveInpu_2">
          <el-option v-for="item in channelModes" :key="item.value" :value="item.value" :label="item.label">
          </el-option>
        </el-select>
      </div>
      <div style="margin-top:0.1rem">
        <el-form :model="editChannelForm.rs485Config" v-if="editChannelForm.channel_type.indexOf('rs')>=0"
          style="text-align: left;" label-position="right" block>
          <el-form-item class="formline_1" label="波特率:" :label-width="formLabelWidth">
            <el-select v-model="editChannelForm.rs485Config.baud_rate" placeholder="选择波特率" class="slaveInpu_2">
              <el-option v-for="item in baudRates" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="formline_1" label="数据位:" :label-width="formLabelWidth">
            <el-select v-model="editChannelForm.rs485Config.data_bits" placeholder="选择数据位" class="slaveInpu_2">
              <el-option v-for="item in dataBits" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="formline_1" label="停止位:" :label-width="formLabelWidth">
            <el-select v-model="editChannelForm.rs485Config.stop_bits" placeholder="选择停止位" class="slaveInpu_2">
              <el-option v-for="item in stopBits" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="formline_1" label="校验位:" :label-width="formLabelWidth">
            <el-select v-model="editChannelForm.rs485Config.parity" placeholder="选择校验位" class="slaveInpu_2">
              <el-option v-for="item in parities" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <el-form :model="editChannelForm.comConfig" v-if="editChannelForm.channel_type.indexOf('com')==0"
          style="text-align: left;" label-position="right" :block="true">
          <el-form-item class="formline_1" label="波特率:" :label-width="formLabelWidth">
            <el-select v-model="editChannelForm.comConfig.baud_rate" placeholder="选择波特率" class="slaveInpu_2">
              <el-option v-for="item in baudRates" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>&nbsp;bps
          </el-form-item>
          <el-form-item class="formline_1" label="数据位:" :label-width="formLabelWidth">
            <el-select v-model="editChannelForm.comConfig.data_bits" placeholder="选择波特率" class="slaveInpu_2">
              <el-option v-for="item in dataBits" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="formline_1" label="停止位:" :label-width="formLabelWidth">
            <el-select v-model="editChannelForm.comConfig.stop_bits" placeholder="选择波特率" class="slaveInpu_2">
              <el-option v-for="item in stopBits" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="formline_1" label="校验位:" :label-width="formLabelWidth">
            <el-select v-model="editChannelForm.comConfig.parity" placeholder="选择波特率" class="slaveInpu_2">
              <el-option v-for="item in parities" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="formline_1" label="断帧时间:" :label-width="formLabelWidth">
            <el-select v-model="editChannelForm.comConfig.timeout" placeholder="选择断帧时间" class="slaveInpu_2">
              <el-option v-for="item in timeoutOptions" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select> <span v-show="editChannelForm.comConfig.timeout!=0">ms</span>
          </el-form-item>
        </el-form>
        <el-form :model="editChannelForm.ethernetConfig" v-if="editChannelForm.channel_type.indexOf('thernet')>=0"
          style="text-align: left;" block>
          <el-form-item label="自动获取IP:" :label-width="formLabelWidth">
            <el-switch v-model="editChannelForm.ethernetConfig.dhcp" :width="stateWidth" class="demo"
              style="display:inline-block;vertical-align:top;" active-color="#13ce66" inactive-color="#ccc"
              active-text="是" inactive-text="否" :active-value="one" :inactive-value="zero">
            </el-switch>
          </el-form-item>
          <el-form-item class="formline_1" style="margin-top:-0.3rem;" label="默认网关:" :label-width="formLabelWidth">
            <el-input class="inpu" v-model="editChannelForm.ethernetConfig.gateway" placeholder="输入本地默认网关"
              :disabled="editChannelForm.ethernetConfig.dhcp==1"></el-input>
          </el-form-item>
          <el-form-item class="formline_1" label="子网掩码:" :label-width="formLabelWidth">
            <el-input class="inpu" v-model="editChannelForm.ethernetConfig.subnet_mask" placeholder="输入本地子网掩码"
              :disabled="editChannelForm.ethernetConfig.dhcp==1"></el-input>
          </el-form-item>
          <el-form-item class="formline_1" label="网关IP:" :label-width="formLabelWidth">
            <el-input class="inpu" v-model="editChannelForm.ethernetConfig.local_ip" placeholder="输入网关IP"
              :disabled="editChannelForm.ethernetConfig.dhcp==1"></el-input>
          </el-form-item>

          <el-form-item class="formline_1 local" label="云盒Port:" :label-width="formLabelWidth">
            <el-input class="inpu" v-model="editChannelForm.ethernetConfig.local_port" placeholder="输入云盒Port"
              :disabled="editChannelForm.ethernetConfig.dhcp==1"></el-input><br>
          </el-form-item>
        </el-form>
        <el-form :model="editChannelForm.loraConfig" v-if="editChannelForm.channel_type.indexOf('ora')>=0"
          style="text-align: left;" block>
          <el-form-item label="通讯信道:" :label-width="formLabelWidth">
            <el-input class="slaveInpu_2" v-model="editChannelForm.loraConfig.channel" placeholder="输入通讯信道">
            </el-input>
            <div class="tip_1">取值范围0-83</div>
          </el-form-item>
          <el-form-item label="模块地址:" :label-width="formLabelWidth">
            <el-input class="slaveInpu_2" v-model="editChannelForm.loraConfig.address" placeholder="输入模块地址">
            </el-input>
            <div class="tip_1">取值范围0-65535</div>
          </el-form-item>
          <el-form-item label="空中速率:" :label-width="formLabelWidth">
            <!-- <el-input class="inpu" v-model="loraConfig.air_rate" placeholder="输入本地IP地址"></el-input> -->
            <el-select v-model="editChannelForm.loraConfig.air_rate" placeholder="选择空中速率" class="slaveInpu_2">
              <el-option v-for="item in speeds" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>&nbsp;bps
          </el-form-item>
          <el-form-item class="formline_1" label="断帧时间:" :label-width="formLabelWidth">
            <el-select v-model="editChannelForm.loraConfig.timeout" placeholder="选择断帧时间" class="slaveInpu_2">
              <el-option v-for="item in timeoutOptions" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select> <span v-show="editChannelForm.loraConfig.timeout!=0">ms</span>
          </el-form-item>
        </el-form>
        <el-form :model="editChannelForm.zigbeeConfig" v-if="editChannelForm.channel_type.indexOf('igbee')>=0"
          style="text-align: left;" block>
          <el-form-item label="通讯信道:" :label-width="formLabelWidth">
            <el-input class="slaveInpu_2" v-model="editChannelForm.zigbeeConfig.channel" placeholder="输入通讯信道">
            </el-input>
            <div class="tip_1">取值范围0-83</div>
          </el-form-item>
          <el-form-item label="PAN ID:" :label-width="formLabelWidth">
            <el-input class="slaveInpu_2" v-model="editChannelForm.zigbeeConfig.pan_id" placeholder="输入PAN ID">
            </el-input>
            <div class="tip_1">取值范围0-65535</div>
          </el-form-item>
        </el-form>
        <el-form :model="editChannelForm.localConfig" v-if="editChannelForm.channel_type.indexOf('ocal')>=0"
          style="text-align: left;" block>
          <el-form-item label="DI数量:" class="formline_1" :label-width="formLabelWidth">
            <el-input class="slaveInpu_2" v-model="editChannelForm.localConfig.di_count"
              placeholder="输入通讯信道"></el-input>
          </el-form-item>
          <el-form-item label="DO数量:" class="formline_1" :label-width="formLabelWidth">
            <el-input class="slaveInpu_2" v-model="editChannelForm.localConfig.do_count"
              placeholder="输入DO数量"></el-input>
          </el-form-item>
          <el-form-item label="AI数量:" class="formline_1" :label-width="formLabelWidth">
            <el-input class="slaveInpu_2" v-model="editChannelForm.localConfig.ai_count"
              placeholder="输入AI数量"></el-input>
          </el-form-item>
          <el-form-item label="AO数量:" class="formline_1" :label-width="formLabelWidth">
            <el-input class="slaveInpu_2" v-model="editChannelForm.localConfig.ao_count"
              placeholder="输入AO数量"></el-input>
          </el-form-item>
          <el-form-item label="温度数量:" class="formline_1" :label-width="formLabelWidth">
            <el-input class="slaveInpu_2" v-model="editChannelForm.localConfig.temp_count"
              placeholder="输入温度数量"></el-input>
          </el-form-item>
          <el-form-item label="PI数量:" class="formline_1" :label-width="formLabelWidth">
            <el-input class="slaveInpu_2" v-model="editChannelForm.localConfig.pi_count"
              placeholder="输入PI数量"></el-input>
          </el-form-item>
        </el-form>
      </div>
      <div style="text-align: right;margin-top:0.6rem;">
        <el-button size="small" @click="editFormVisible = false">取 消</el-button>
        <el-button type="primary" size="small" @click="updateChannel">确 定</el-button>
      </div>
    </el-dialog>
    <el-dialog :visible.sync="addSlaveFormVisible" v-el-dialog-drag v-el-dialog-drag-width
      :width="screenWidth>1600?'55%':'68%'" append-to-body :show-close="close" top="50px" class="dial">
      <div class="toptit">
        <span>添加子设备</span>
        <span style="float:right;cursor: pointer;" @click="addSlaveFormVisible = false">关闭</span>
      </div>
      <div class="slaveInfo">
        <!-- <span class="leftName">基本信息</span> -->
        <el-form :model="addSlaveForm" inline class="addform">
          <el-form-item label="子设备名称:" :label-width="formLabelWidth">
            <el-input v-model="addSlaveForm.name" class="inpu" placeholder="输入子设备名称"></el-input>
            <!-- <div class="tip_1" style="width:5rem;">子设备ID的别名,仅用于显示,勿重名</div> -->
          </el-form-item>
          <el-form-item v-if="deviceData.app_scene!=3" label="数据点模板:" :label-width="formLabelWidth">
            <el-select v-model="addSlaveForm.template" placeholder="数据点模板" class="inpu">
              <el-option v-for="item in moulds" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <br>
          <el-form-item label="选择端口:" :label-width="formLabelWidth" class="for_1366">
            <el-select v-model="addSlaveForm.channel" placeholder="选择端口" class="inpu"
              @change="changeAddSlaveChannel(addSlaveForm.channel)">
              <el-option v-for="item in slaveChannels" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="选择协议:" :label-width="formLabelWidth" class="for_1366">

            <el-select v-model="addSlaveForm.slave_protocol" placeholder="协议选择" class="inpu"
              @change="changeAddProtocol">
              <el-option v-for="item in protocols" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item><br>
          <el-form-item label="子设备站号:" :label-width="formLabelWidth" class="for_1366">
            <el-input v-model="addSlaveForm.slave_addr" class="inpu" @input="changeAddAddr"
              placeholder="输入子设备站号"></el-input>
          </el-form-item>
          <el-form-item label="子设备ID:" :label-width="formLabelWidth" class="for_1366">
            <el-input v-model="addSlaveForm.num" class="inpu" placeholder="输入子设备ID"></el-input>
          </el-form-item>
        </el-form>
      </div>
      <div class="argmentBox">
        <!-- <span class="leftName">配置参数</span> -->
        <el-form :model="modbusMaster" inline class="addform"
          v-if="addSlaveForm.slave_protocol.indexOf('rtu_master')>=0 || addSlaveForm.slave_protocol.indexOf('ascii')>=0"
          style="height:auto;">
          <el-form-item label="轮询周期:" :label-width="formLabelWidth2" class="formline_1" style="height:1.2rem;">
            <el-input v-model="modbusMaster.poll_cycle" class="slaveInpu_2" type="number" min="0" step="10">
            </el-input>
            <div class="tip_1">单位:s(秒)</div>
          </el-form-item>
          <el-form-item label="指令间隔:" :label-width="formLabelWidth2" class="formline_1" style="height:1.2rem;">
            <el-input v-model="modbusMaster.poll_interval" class="slaveInpu_2" type="number" min="10" step="10">
            </el-input>
            <div class="tip_1">单位:ms(毫秒)</div>
          </el-form-item>
          <el-form-item label="超时时长:" :label-width="formLabelWidth2" class="formline_1" style="height:1.2rem;">
            <el-input v-model="modbusMaster.response_timeout" class="slaveInpu_2" type="number" min="1000" step="500">
            </el-input>
            <div class="tip_1">单位:ms(毫秒)</div>
          </el-form-item><br>
          <el-form-item label="4区16位写功能选择:" :label-width="formLabelWidth2" class="formline_1">
            <!-- <el-input v-model="modbusMaster.write16_cmd" class="inpu"></el-input> -->
            <el-select v-model="modbusMaster.write16_cmd" class="slaveInpu_2">
              <el-option v-for="item in cmds_16" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="16位整数解码顺序:" :label-width="formLabelWidth2" class="formline_1">
            <el-select v-model="modbusMaster.int16_order" class="slaveInpu_2">
              <el-option v-for="item in orders_16" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="32位整数解码顺序:" :label-width="formLabelWidth2" class="formline_1">
            <el-select v-model="modbusMaster.int32_order" class="slaveInpu_2">
              <el-option v-for="item in orders_32" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item><br>
          <el-form-item label="32位浮点数解码顺序:" :label-width="formLabelWidth2" class="formline_1">
            <el-select v-model="modbusMaster.float_order" class="slaveInpu_2">
              <el-option v-for="item in orders_32" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="64位整数解码顺序:" :label-width="formLabelWidth2" class="formline_1">
            <el-select v-model="modbusMaster.int64_order" class="slaveInpu_2">
              <el-option v-for="item in orders_64" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="64位浮点数解码顺序:" :label-width="formLabelWidth2" class="formline_1">
            <el-select v-model="modbusMaster.double_order" class="slaveInpu_2">
              <el-option v-for="item in orders_64" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item><br>
          <el-form-item label="CRC检验方式:" :label-width="formLabelWidth2" class="formline_1">
            <el-select v-model="modbusMaster.crc_mode" placeholder="CRC检验方式" class="slaveInpu_2">
              <el-option v-for="item in crc_modes" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="最大采集长度:" :label-width="formLabelWidth2" class="formline_1">
            <el-input v-model="modbusMaster.max_length" class="slaveInpu_2" type="number" max="125" step="5">
            </el-input>
            <span class="tip_1">最大值:125</span>
          </el-form-item>
          <div style="border-top:1px dashed #ccc;margin-top:0.1rem;padding-top:0.1rem;">
            <div class="tip_1" style="width:100%;color:red;padding-left:0.7rem;margin-bottom:0.2rem;font-size:0.3rem;">
              注：以下为状态寄存器功能,需要固件版本的支持,最低版本V5.1.0,如不确定版本号,请不要使用!</div>
            <el-form-item label="下发频率:" :label-width="formLabelWidth2" class="formline_1">
              <el-input v-model="modbusMaster.state_reg.push_interval" class="slaveInpu_2" type="number" min="60"
                step="10">
              </el-input>
              <span class="tip_1">单位:s(秒),最低60s</span><el-button size="mini"
                style="color:deepskyblue;margin-left:0.4rem;" @click="argmentInfo">参数说明</el-button>
            </el-form-item><br>
            <el-form-item label="心跳使能:" :label-width="formLabelWidth2" class="formline_1">
              <el-switch v-model="modbusMaster.state_reg.ping_enable" :width="stateWidth" class="demo"
                style="display:inline-block;vertical-align:top;margin-left:-0.9rem!important;" active-color="#13ce66"
                inactive-color="#ccc" active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
              </el-switch>
            </el-form-item>
            <el-form-item label="心跳地址:" :label-width="formLabelWidth2" class="formline_1">
              <el-input v-model="modbusMaster.state_reg.ping_address" class="slaveInpu_2" placeholder="">
              </el-input>
            </el-form-item><br>
            <el-form-item label="状态使能:" :label-width="formLabelWidth2" class="formline_1">
              <el-switch v-model="modbusMaster.state_reg.state_enable" :width="stateWidth" class="demo"
                style="display:inline-block;vertical-align:top;margin-left:-0.9rem!important;" active-color="#13ce66"
                inactive-color="#ccc" active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
              </el-switch>
            </el-form-item>
            <el-form-item label="状态地址:" :label-width="formLabelWidth2" class="formline_1">
              <el-input v-model="modbusMaster.state_reg.state_address" class="slaveInpu_2" placeholder="">
              </el-input>
            </el-form-item>
          </div>
        </el-form>
        <el-form :model="modbusClient" inline class="addform"
          v-if="addSlaveForm.slave_protocol.indexOf('lient')>=0 || addSlaveForm.slave_protocol.indexOf('ver')>=0"
          style="height:auto;">
          <el-form-item class="formline_1" label="Server_IP:" :label-width="formLabelWidth">
            <el-input class="inpu" v-model="modbusClient.server_ip" placeholder="输入Server IP地址"></el-input>
          </el-form-item>
          <el-form-item class="formline_1" label="Server_Port:" label-width="96px">
            <el-input class="slaveInpu_2" v-model="modbusClient.server_port" placeholder="输入Server端口号">
            </el-input>
          </el-form-item><br>
          <el-form-item label="轮询周期:" :label-width="formLabelWidth2" class="formline_1" style="height:1.2rem;">
            <el-input v-model="modbusClient.poll_cycle" class="slaveInpu_2" type="number" min="0" step="10">
            </el-input>
            <div class="tip_1">单位:s(秒)</div>
          </el-form-item>
          <el-form-item label="指令间隔:" :label-width="formLabelWidth2" class="formline_1" style="height:1.2rem;">
            <el-input v-model="modbusClient.poll_interval" class="slaveInpu_2" type="number" min="10" step="10">
            </el-input>
            <div class="tip_1">单位:ms(毫秒)</div>
          </el-form-item>
          <el-form-item label="超时时长:" :label-width="formLabelWidth2" class="formline_1" style="height:1.2rem;">
            <el-input v-model="modbusClient.response_timeout" class="slaveInpu_2" type="number" min="1000" step="500">
            </el-input>
            <div class="tip_1">单位:ms(毫秒)</div>
          </el-form-item><br>
          <el-form-item label="4区16位写功能选择:" :label-width="formLabelWidth2" class="formline_1">
            <!-- <el-input v-model="modbusMaster.write16_cmd" class="inpu"></el-input> -->
            <el-select v-model="modbusClient.write16_cmd" class="slaveInpu_2">
              <el-option v-for="item in cmds_16" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="16位整数解码顺序:" :label-width="formLabelWidth2" class="formline_1">
            <el-select v-model="modbusClient.int16_order" class="slaveInpu_2">
              <el-option v-for="item in orders_16" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="32位整数解码顺序:" :label-width="formLabelWidth2" class="formline_1">
            <el-select v-model="modbusClient.int32_order" class="slaveInpu_2">
              <el-option v-for="item in orders_32" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item><br>
          <el-form-item label="32位浮点数解码顺序:" :label-width="formLabelWidth2" class="formline_1">
            <el-select v-model="modbusClient.float_order" class="slaveInpu_2">
              <el-option v-for="item in orders_32" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="64位整数解码顺序:" :label-width="formLabelWidth2" class="formline_1">
            <el-select v-model="modbusClient.int64_order" class="slaveInpu_2">
              <el-option v-for="item in orders_64" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="64位浮点数解码顺序:" :label-width="formLabelWidth2" class="formline_1">
            <el-select v-model="modbusClient.double_order" class="slaveInpu_2">
              <el-option v-for="item in orders_64" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item><br>
          <el-form-item label="最大采集长度:" :label-width="formLabelWidth2" class="formline_1">
            <el-input v-model="modbusClient.max_length" class="slaveInpu_2" type="number" max="125" step="5">
            </el-input>
            <span class="tip_1">最大值:125</span>
          </el-form-item>
          <div style="border-top:1px dashed #ccc;margin-top:0.1rem;padding-top:0.1rem;">
            <div class="tip_1" style="width:100%;color:red;padding-left:0.8rem;margin-bottom:0.2rem;font-size:0.3rem;">
              注：以下为状态寄存器功能,需要固件版本的支持,最低版本V5.1.0,如不确定版本号,请不要使用!</div>
            <el-form-item label="下发频率:" :label-width="formLabelWidth2" class="formline_1">
              <el-input v-model="modbusClient.state_reg.push_interval" class="slaveInpu_2" type="number" min="60"
                step="10">
              </el-input>
              <span class="tip_1">单位:s(秒),最低60s</span><el-button size="mini"
                style="color:deepskyblue;margin-left:0.4rem;" @click="argmentInfo">参数说明</el-button>
            </el-form-item><br>
            <el-form-item label="心跳使能:" :label-width="formLabelWidth2" class="formline_1">
              <el-switch v-model="modbusClient.state_reg.ping_enable" :width="stateWidth" class="demo"
                style="display:inline-block;vertical-align:top;margin-left:-0.9rem!important;" active-color="#13ce66"
                inactive-color="#ccc" active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
              </el-switch>
            </el-form-item>
            <el-form-item label="心跳地址:" :label-width="formLabelWidth2" class="formline_1">
              <el-input v-model="modbusClient.state_reg.ping_address" class="slaveInpu_2" placeholder="">
              </el-input>
            </el-form-item><br>
            <el-form-item label="状态使能:" :label-width="formLabelWidth2" class="formline_1">
              <el-switch v-model="modbusClient.state_reg.state_enable" :width="stateWidth" class="demo"
                style="display:inline-block;vertical-align:top;margin-left:-0.9rem!important;" active-color="#13ce66"
                inactive-color="#ccc" active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
              </el-switch>
            </el-form-item>
            <el-form-item label="状态地址:" :label-width="formLabelWidth2" class="formline_1">
              <el-input v-model="modbusClient.state_reg.state_address" class="slaveInpu_2" placeholder="">
              </el-input>
            </el-form-item>
          </div>
        </el-form>
        <el-form :model="localSlave" inline class="addform" v-if="addSlaveForm.slave_protocol=='modbus'"
          style="height:auto;">
          <el-form-item label="Ethernet_0使能:" :label-width="formLabelWidth2" class="formline_1">
            <el-switch v-model="localSlave.ethernet_0" :width="stateWidth" class="demo"
              style="display:inline-block;vertical-align:top;" active-color="#13ce66" inactive-color="#ccc"
              active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
            </el-switch>
          </el-form-item>
          <el-form-item label="RS485_0使能:" :label-width="formLabelWidth" class="formline_1">
            <el-switch v-model="localSlave.rs485_0" :width="stateWidth" class="demo"
              style="display:inline-block;vertical-align:top;" active-color="#13ce66" inactive-color="#ccc"
              active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
            </el-switch>
          </el-form-item>
          <el-form-item label="RS485_1使能:" :label-width="formLabelWidth" class="formline_1">
            <el-switch v-model="localSlave.rs485_1" :width="stateWidth" class="demo"
              style="display:inline-block;vertical-align:top;" active-color="#13ce66" inactive-color="#ccc"
              active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
            </el-switch>
          </el-form-item><br>
          <el-form-item label="RS485_2使能:" :label-width="formLabelWidth2" class="formline_1">
            <el-switch v-model="localSlave.rs485_2" :width="stateWidth" class="demo"
              style="display:inline-block;vertical-align:top;" active-color="#13ce66" inactive-color="#ccc"
              active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
            </el-switch>
          </el-form-item>
          <el-form-item label="RS232_0使能:" :label-width="formLabelWidth" class="formline_1">
            <el-switch v-model="localSlave.rs232_0" :width="stateWidth" class="demo"
              style="display:inline-block;vertical-align:top;" active-color="#13ce66" inactive-color="#ccc"
              active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
            </el-switch>
          </el-form-item>
          <el-form-item label="响应延时(秒):" :label-width="formLabelWidth" class="formline_1">
            <el-input v-model="localSlave.response_delay" class="slaveInpu_2" placeholder="默认为10秒">
            </el-input>
          </el-form-item>
          <div style="border-top:1px dashed #ccc;margin-top:0.1rem;padding-top:0.1rem;">
            <div class="tip_1" style="width:100%;color:red;padding-left:0.6rem;margin-bottom:0.2rem;font-size:0.3rem;">
              注：以下为状态寄存器功能,需要固件版本的支持,最低版本V5.1.0,如不确定版本号,请不要使用!</div>
            <el-form-item label="下发频率:" :label-width="formLabelWidth2" class="formline_1">
              <el-input v-model="localSlave.state_reg.push_interval" class="slaveInpu_2" type="number" min="60"
                step="10">
              </el-input>
              <span class="tip_1">单位:s(秒),最低60s</span><el-button size="mini"
                style="color:deepskyblue;margin-left:0.4rem;" @click="argmentInfo">参数说明</el-button>
            </el-form-item><br>
            <el-form-item label="心跳使能:" :label-width="formLabelWidth2" class="formline_1">
              <el-switch v-model="localSlave.state_reg.ping_enable" :width="stateWidth" class="demo"
                style="display:inline-block;vertical-align:top;margin-left:-0.9rem!important;" active-color="#13ce66"
                inactive-color="#ccc" active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
              </el-switch>
            </el-form-item>
            <el-form-item label="心跳地址:" :label-width="formLabelWidth" class="formline_1">
              <el-input v-model="localSlave.state_reg.ping_address" class="slaveInpu_2" placeholder="">
              </el-input>
            </el-form-item><br>
            <el-form-item label="状态使能:" :label-width="formLabelWidth2" class="formline_1">
              <el-switch v-model="localSlave.state_reg.state_enable" :width="stateWidth" class="demo"
                style="display:inline-block;vertical-align:top;margin-left:-0.9rem!important;" active-color="#13ce66"
                inactive-color="#ccc" active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
              </el-switch>
            </el-form-item>
            <el-form-item label="状态地址:" :label-width="formLabelWidth" class="formline_1">
              <el-input v-model="localSlave.state_reg.state_address" class="slaveInpu_2" placeholder="">
              </el-input>
            </el-form-item>
          </div>

        </el-form>
        <el-form :model="s7_200_ppi" inline class="addform"
          v-if="addSlaveForm.slave_protocol.indexOf('pi')>=0 || addSlaveForm.slave_protocol.indexOf('rogram')>=0"
          style="height:auto;">
          <el-form-item v-if="addSlaveForm.slave_protocol.indexOf('rogram')>=0" label="PLC类型:"
            :label-width="formLabelWidth" class="formline_1" style="height:1.1rem;">
            <el-select v-model="s7_200_ppi.plc_type" placeholder="PLC类型选择" class="slaveInpu_2">
              <el-option v-for="item in protocols_PLC" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item><br>
          <el-form-item label="轮询周期:" :label-width="formLabelWidth" class="formline_1" style="height:1.1rem;">
            <el-input v-model="s7_200_ppi.poll_cycle" class="slaveInpu_2" type="number" min="0" step="10"></el-input>
            <div class="tip_1">单位:s(秒)</div>
          </el-form-item>
          <el-form-item label="指令间隔:" :label-width="formLabelWidth" class="formline_1" style="height:1.1rem;">
            <el-input v-model="s7_200_ppi.poll_interval" class="slaveInpu_2" type="number" min="10" step="10">
            </el-input>
            <div class="tip_1">单位:ms(毫秒)</div>
          </el-form-item>
          <el-form-item label="超时时长:" :label-width="formLabelWidth" class="formline_1" style="height:1.1rem;">
            <el-input v-model="s7_200_ppi.response_timeout" class="slaveInpu_2" type="number" min="1000" step="500">
            </el-input>
            <div class="tip_1">单位:ms(毫秒)</div>
          </el-form-item>
          <div style="border-top:1px dashed #ccc;margin-top:0.1rem;padding-top:0.1rem;">
            <div class="tip_1" style="width:100%;color:red;padding-left:0.8rem;margin-bottom:0.2rem;font-size:0.3rem;">
              注：以下为状态寄存器功能,需要固件版本的支持,最低版本V5.1.0,如不确定版本号,请不要使用!</div>
            <el-form-item label="下发频率:" :label-width="formLabelWidth" class="formline_1">
              <el-input v-model="s7_200_ppi.state_reg.push_interval" class="slaveInpu_2" type="number" min="60"
                step="10">
              </el-input>
              <span class="tip_1">单位:s(秒),最低60s</span><el-button size="mini"
                style="color:deepskyblue;margin-left:0.4rem;" @click="argmentInfo">参数说明</el-button>
            </el-form-item><br>
            <el-form-item label="心跳使能:" :label-width="formLabelWidth" class="formline_1">
              <el-switch v-model="s7_200_ppi.state_reg.ping_enable" :width="stateWidth" class="demo"
                style="display:inline-block;vertical-align:top;margin-left:-0.9rem!important;" active-color="#13ce66"
                inactive-color="#ccc" active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
              </el-switch>
            </el-form-item>
            <el-form-item label="心跳地址:" :label-width="formLabelWidth" class="formline_1">
              <el-input v-model="s7_200_ppi.state_reg.ping_address" class="slaveInpu_2" placeholder="">
              </el-input>
            </el-form-item><br>
            <el-form-item label="状态使能:" :label-width="formLabelWidth" class="formline_1">
              <el-switch v-model="s7_200_ppi.state_reg.state_enable" :width="stateWidth" class="demo"
                style="display:inline-block;vertical-align:top;margin-left:-0.9rem!important;" active-color="#13ce66"
                inactive-color="#ccc" active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
              </el-switch>
            </el-form-item>
            <el-form-item label="状态地址:" :label-width="formLabelWidth" class="formline_1">
              <el-input v-model="s7_200_ppi.state_reg.state_address" class="slaveInpu_2" placeholder="">
              </el-input>
            </el-form-item>
          </div>
        </el-form>
        <el-form :model="dl_T645" inline class="addform" v-if="addSlaveForm.slave_protocol.indexOf('645')>=0"
          style="height:auto;">
          <el-form-item label="轮询周期:" :label-width="formLabelWidth" class="formline_1" style="height:1.2rem;">
            <el-input v-model="dl_T645.poll_cycle" class="slaveInpu_2" type="number" min="0" step="10"></el-input>
            <div class="tip_1">单位:s(秒)</div>
          </el-form-item>
          <el-form-item label="指令间隔:" :label-width="formLabelWidth" class="formline_1" style="height:1.2rem;">
            <el-input v-model="dl_T645.poll_interval" class="slaveInpu_2" type="number" min="10" step="10">
            </el-input>
            <div class="tip_1">单位:ms(毫秒)</div>
          </el-form-item>
          <el-form-item label="超时时长:" :label-width="formLabelWidth" class="formline_1" style="height:1.2rem;">
            <el-input v-model="dl_T645.response_timeout" class="slaveInpu_2" type="number" min="1000" step="500">
            </el-input>
            <div class="tip_1">单位:ms(毫秒)</div>
          </el-form-item>

        </el-form>
        <el-form :model="s7_1200_1500" inline class="addform"
          v-if="addSlaveForm.slave_protocol.indexOf('mart')>=0 || addSlaveForm.slave_protocol.indexOf('1200')>=0 || addSlaveForm.slave_protocol.indexOf('1500')>=0 || addSlaveForm.slave_protocol.indexOf('300')>=0 || addSlaveForm.slave_protocol.toLowerCase()=='s7_200'"
          style="height:auto;">
          <el-form-item class="formline_1" label="PLC IP:" :label-width="formLabelWidth">
            <el-input class="inpu" v-model="s7_1200_1500.server_ip" placeholder="输入PLC IP地址"></el-input>
            <span class="tip_1" style="margin-left:0.8rem;">PLC端口固定为102，不可更改</span>
          </el-form-item>
          <el-form-item class="formline_1" label="PLC端口:" :label-width="formLabelWidth" v-show="false">
            <el-input class="inpu_2" v-model="s7_1200_1500.server_port" placeholder="输入PLC端口号"></el-input>
          </el-form-item>
          <br>
          <el-form-item label="轮询周期:" :label-width="formLabelWidth" class="formline_1" style="height:1.2rem;">
            <el-input v-model="s7_1200_1500.poll_cycle" class="slaveInpu_2" type="number" min="0" step="10">
            </el-input>
            <div class="tip_1">单位:s(秒)</div>
          </el-form-item>
          <el-form-item label="指令间隔:" :label-width="formLabelWidth" class="formline_1" style="height:1.2rem;">
            <el-input v-model="s7_1200_1500.poll_interval" class="slaveInpu_2" type="number" min="10" step="10">
            </el-input>
            <div class="tip_1">单位:ms(毫秒)</div>
          </el-form-item>
          <el-form-item label="超时时长:" :label-width="formLabelWidth" class="formline_1" style="height:1.2rem;">
            <el-input v-model="s7_1200_1500.response_timeout" class="slaveInpu_2" type="number" min="1000" step="500">
            </el-input>
            <div class="tip_1">单位:ms(毫秒)</div>
          </el-form-item><br>
          <el-form-item label="机架号:" :label-width="formLabelWidth" class="formline_1">
            <el-input v-model="s7_1200_1500.rack_num" class="slaveInpu_2" placeholder="输入机架号"></el-input>
          </el-form-item>
          <el-form-item label="槽号:" :label-width="formLabelWidth" class="formline_1">
            <el-input v-model="s7_1200_1500.slot_num" class="slaveInpu_2" placeholder="输入槽号"></el-input>
          </el-form-item>
          <div style="border-top:1px dashed #ccc;margin-top:0.1rem;padding-top:0.1rem;">
            <div class="tip_1" style="width:100%;color:red;padding-left:0.8rem;margin-bottom:0.2rem;font-size:0.3rem;">
              注：以下为状态寄存器功能,需要固件版本的支持,最低版本V5.1.0,如不确定版本号,请不要使用!</div>
            <el-form-item label="下发频率:" :label-width="formLabelWidth" class="formline_1">
              <el-input v-model="s7_1200_1500.state_reg.push_interval" class="slaveInpu_2" type="number" min="60"
                step="10">
              </el-input>
              <span class="tip_1">单位:s(秒),最低60s</span><el-button size="mini"
                style="color:deepskyblue;margin-left:0.4rem;" @click="argmentInfo">参数说明</el-button>
            </el-form-item><br>
            <el-form-item label="心跳使能:" :label-width="formLabelWidth" class="formline_1">
              <el-switch v-model="s7_1200_1500.state_reg.ping_enable" :width="stateWidth" class="demo"
                style="display:inline-block;vertical-align:top;margin-left:-0.9rem!important" active-color="#13ce66"
                inactive-color="#ccc" active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
              </el-switch>
            </el-form-item>
            <el-form-item label="心跳地址:" :label-width="formLabelWidth" class="formline_1">
              <el-input v-model="s7_1200_1500.state_reg.ping_address" class="slaveInpu_2" placeholder="">
              </el-input>
            </el-form-item><br>
            <el-form-item label="状态使能:" :label-width="formLabelWidth" class="formline_1">
              <el-switch v-model="s7_1200_1500.state_reg.state_enable" :width="stateWidth" class="demo"
                style="display:inline-block;vertical-align:top;margin-left:-0.9rem!important" active-color="#13ce66"
                inactive-color="#ccc" active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
              </el-switch>
            </el-form-item>
            <el-form-item label="状态地址:" :label-width="formLabelWidth" class="formline_1">
              <el-input v-model="s7_1200_1500.state_reg.state_address" class="slaveInpu_2" placeholder="">
              </el-input>
            </el-form-item>
          </div>
        </el-form>
        <el-form :model="fx_serial_port" inline class="addform" v-if="addSlaveForm.slave_protocol.indexOf('erial')>=0"
          style="height:auto;">
          <el-form-item label="PLC类型:" :label-width="formLabelWidth" class="formline_1" style="height:1.2rem;">
            <el-select v-model="fx_serial_port.plc_type" placeholder="PLC类型选择" class="slaveInpu_2">
              <el-option v-for="item in protocols_PLC" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="协议格式:" :label-width="formLabelWidth" class="formline_1">
            <el-select v-model="fx_serial_port.protocol_format" class="slaveInpu_2">
              <el-option v-for="item in famtterFxs" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="是否效验:" :label-width="formLabelWidth" class="formline_1">
            <el-select v-model="fx_serial_port.is_check" class="slaveInpu_2">
              <el-option v-for="item in checkFxs" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>

          </el-form-item><br>
          <el-form-item label="轮询周期:" :label-width="formLabelWidth" class="formline_1"
            style="height:1.2rem;margin-top:-0.4rem;">
            <el-input v-model="fx_serial_port.poll_cycle" class="slaveInpu_2" type="number" min="0"
              step="10"></el-input>
            <div class="tip_1">单位:s(秒)</div>
          </el-form-item>
          <el-form-item label="指令间隔:" :label-width="formLabelWidth" class="formline_1"
            style="height:1.2rem;margin-top:-0.4rem;">
            <el-input v-model="fx_serial_port.poll_interval" class="slaveInpu_2" type="number" min="10" step="10">
            </el-input>
            <div class="tip_1">单位:ms(毫秒)</div>
          </el-form-item>
          <el-form-item label="超时时长:" :label-width="formLabelWidth" class="formline_1"
            style="height:1.2rem;margin-top:-0.4rem;">
            <el-input v-model="fx_serial_port.response_timeout" class="slaveInpu_2" type="number" min="1000" step="500">
            </el-input>
            <div class="tip_1">单位:ms(毫秒)</div>
          </el-form-item>
          <div style="border-top:1px dashed #ccc;margin-top:0.1rem;padding-top:0.1rem;">
            <div class="tip_1" style="width:100%;color:red;padding-left:0.8rem;margin-bottom:0.2rem;font-size:0.3rem;">
              注：以下为状态寄存器功能,需要固件版本的支持,最低版本V5.1.0,如不确定版本号,请不要使用!</div>
            <el-form-item label="下发频率:" :label-width="formLabelWidth" class="formline_1">
              <el-input v-model="fx_serial_port.state_reg.push_interval" class="slaveInpu_2" type="number" min="60"
                step="10">
              </el-input>
              <span class="tip_1">单位:s(秒),最低60s</span><el-button size="mini"
                style="color:deepskyblue;margin-left:0.4rem;" @click="argmentInfo">参数说明</el-button>
            </el-form-item><br>
            <el-form-item label="心跳使能:" :label-width="formLabelWidth" class="formline_1" style="margin-top:-0.2rem;">
              <el-switch v-model="fx_serial_port.state_reg.ping_enable" :width="stateWidth" class="demo"
                style="display:inline-block;vertical-align:top;margin-left:-0.9rem!important;" active-color="#13ce66"
                inactive-color="#ccc" active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
              </el-switch>
            </el-form-item>
            <el-form-item label="心跳地址:" :label-width="formLabelWidth" class="formline_1" style="margin-top:-0.2rem;">
              <el-input v-model="fx_serial_port.state_reg.ping_address" class="slaveInpu_2" placeholder="">
              </el-input>
            </el-form-item><br>
            <el-form-item label="状态使能:" :label-width="formLabelWidth" class="formline_1">
              <el-switch v-model="fx_serial_port.state_reg.state_enable" :width="stateWidth" class="demo"
                style="display:inline-block;vertical-align:top;margin-left:-0.9rem!important;" active-color="#13ce66"
                inactive-color="#ccc" active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
              </el-switch>
            </el-form-item>
            <el-form-item label="状态地址:" :label-width="formLabelWidth" class="formline_1">
              <el-input v-model="fx_serial_port.state_reg.state_address" class="slaveInpu_2" placeholder="">
              </el-input>
            </el-form-item>
          </div>
        </el-form>
      </div>
      <div style="text-align: right;">
        <el-button size="small" @click="addSlaveFormVisible = false">取 消</el-button>
        <el-button type="primary" size="small" @click="addSlave">确 定</el-button>
      </div>
    </el-dialog>
    <el-dialog :visible.sync="editSlaveFormVisible" v-el-dialog-drag v-el-dialog-drag-width
      :width="screenWidth>1600?'55%':'68%'" append-to-body :show-close="close" top="50px" class="dial">
      <div class="toptit">
        <span>编辑子设备</span>
        <span style="float:right;cursor: pointer;" @click="editSlaveFormVisible = false">关闭</span>
      </div>
      <div class="slaveInfo">
        <!-- <span class="leftName">基本信息</span> -->
        <el-form :model="editSlaveForm" inline class="addform">
          <el-form-item label="子设备名称:" :label-width="formLabelWidth">
            <el-input v-model="editSlaveForm.name" class="inpu" placeholder="输入子设备名称"></el-input>
            <!-- <div class="tip_1" style="width:5rem;">为子设备ID的别名，仅用于显示</div> -->
          </el-form-item>
          <el-form-item v-if="deviceData.app_scene!=3" label="数据点模板:" :label-width="formLabelWidth" class="formline_1">
            <el-select v-model="editSlaveForm.template" placeholder="数据点模板" class="inpu">
              <el-option v-for="item in moulds" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <br>
          <el-form-item label="当前端口:" :label-width="formLabelWidth" class="for_1366">
            <!-- <el-select v-model="editSlaveForm.channel" placeholder="选择端口" class="inpu"
							@change="changeEditSlaveChannel(editSlaveForm.channel)"> -->
            <el-select v-model="editSlaveForm.channel" placeholder="当前端口" class="inpu" disabled>
              <el-option v-for="item in slaveChannels" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="选择协议:" :label-width="formLabelWidth" class="for_1366">
            <el-select v-model="editProtocol" placeholder="协议选择" class="inpu" @change="changeEditProtocol"
              :disabled="editSlaveForm.sensors_count!=0">
              <el-option v-for="item in protocols" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item><br>
          <el-form-item label="子设备站号:" :label-width="formLabelWidth" class="for_1366">
            <el-input v-model="editSlaveForm.slave_addr" class="inpu" @input="changeEditAddr"
              placeholder="输入子设备站号"></el-input>
          </el-form-item>
          <el-form-item label="子设备ID:" :label-width="formLabelWidth" class="for_1366">
            <el-input v-model="editSlaveForm.num" class="inpu" placeholder="输入子设备ID"></el-input>
          </el-form-item>
        </el-form>
      </div>
      <div class="argmentBox">
        <el-form :model="editModbusMaster" inline class="addform"
          v-if="editProtocol.indexOf('rtu_master')>=0 || editProtocol.indexOf('ascii')>=0" style="height:auto;">
          <el-form-item label="轮询周期:" :label-width="formLabelWidth2" class="formline_1" style="height:1.2rem;">
            <el-input v-model="editModbusMaster.poll_cycle" class="slaveInpu_2" type="number" min="0" step="10">
            </el-input>
            <div class="tip_1">单位:s(秒)</div>
          </el-form-item>
          <el-form-item label="指令间隔:" :label-width="formLabelWidth2" class="formline_1" style="height:1.2rem;">
            <el-input v-model="editModbusMaster.poll_interval" class="slaveInpu_2" type="number" min="10" step="10">
            </el-input>
            <div class="tip_1">单位:ms(毫秒)</div>
          </el-form-item>
          <el-form-item label="超时时长:" :label-width="formLabelWidth2" class="formline_1" style="height:1.2rem;">
            <el-input v-model="editModbusMaster.response_timeout" class="slaveInpu_2" type="number" min="1000"
              step="500">
            </el-input>
            <div class="tip_1">单位:ms(毫秒)</div>
          </el-form-item><br>
          <el-form-item label="4区16位写功能选择:" :label-width="formLabelWidth2" class="formline_1">
            <!-- <el-input v-model="modbusMaster.write16_cmd" class="inpu"></el-input> -->
            <el-select v-model="editModbusMaster.write16_cmd" class="slaveInpu_2">
              <el-option v-for="item in cmds_16" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="16位整数解码顺序:" :label-width="formLabelWidth2" class="formline_1">
            <el-select v-model="editModbusMaster.int16_order" class="slaveInpu_2">
              <el-option v-for="item in orders_16" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="32位整数解码顺序:" :label-width="formLabelWidth2" class="formline_1">
            <el-select v-model="editModbusMaster.int32_order" class="slaveInpu_2">
              <el-option v-for="item in orders_32" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item><br>
          <el-form-item label="32位浮点数解码顺序:" :label-width="formLabelWidth2" class="formline_1">
            <el-select v-model="editModbusMaster.float_order" class="slaveInpu_2">
              <el-option v-for="item in orders_32" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="64位整数解码顺序:" :label-width="formLabelWidth2" class="formline_1">
            <el-select v-model="editModbusMaster.int64_order" class="slaveInpu_2">
              <el-option v-for="item in orders_64" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="64位浮点数解码顺序:" :label-width="formLabelWidth2" class="formline_1">
            <el-select v-model="editModbusMaster.double_order" class="slaveInpu_2">
              <el-option v-for="item in orders_64" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item><br>
          <el-form-item label="CRC检验方式:" :label-width="formLabelWidth2" class="formline_1">
            <el-select v-model="editModbusMaster.crc_mode" placeholder="CRC检验方式" class="slaveInpu_2">
              <el-option v-for="item in crc_modes" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="最大采集长度:" :label-width="formLabelWidth2" class="formline_1">
            <el-input v-model="editModbusMaster.max_length" class="slaveInpu_2" type="number" max="125" step="5">
            </el-input>
            <span class="tip_1">最大值:125</span>
          </el-form-item>
          <div v-if="editModbusMaster.state_reg"
            style="border-top:1px dashed #ccc;margin-top:0.1rem;padding-top:0.1rem;">
            <div class="tip_1" style="width:100%;color:red;padding-left:1rem;margin-bottom:0.2rem;font-size:0.3rem;">
              注：以下为状态寄存器功能，需要固件版本的支持,最低版本V5.1.0,如不确定版本号,请不要使用!</div>
            <el-form-item label="下发频率:" :label-width="formLabelWidth2" class="formline_1">
              <el-input v-model="editModbusMaster.state_reg.push_interval" class="slaveInpu_2" type="number" min="60"
                step="10">
              </el-input>
              <span class="tip_1">单位:s(秒),最低60s</span>
            </el-form-item><br>
            <el-form-item label="心跳使能:" :label-width="formLabelWidth2" class="formline_1">
              <el-switch v-model="editModbusMaster.state_reg.ping_enable" :width="stateWidth" class="demo"
                style="display:inline-block;vertical-align:top;margin-left:-0.9rem!important;" active-color="#13ce66"
                inactive-color="#ccc" active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
              </el-switch>
            </el-form-item>
            <el-form-item label="心跳地址:" :label-width="formLabelWidth2" class="formline_1">
              <el-input v-model="editModbusMaster.state_reg.ping_address" class="slaveInpu_2" placeholder="">
              </el-input>
            </el-form-item><br>
            <el-form-item label="状态使能:" :label-width="formLabelWidth2" class="formline_1">
              <el-switch v-model="editModbusMaster.state_reg.state_enable" :width="stateWidth" class="demo"
                style="display:inline-block;vertical-align:top;margin-left:-0.9rem!important" active-color="#13ce66"
                inactive-color="#ccc" active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
              </el-switch>
            </el-form-item>
            <el-form-item label="状态地址:" :label-width="formLabelWidth2" class="formline_1">
              <el-input v-model="editModbusMaster.state_reg.state_address" class="slaveInpu_2" placeholder="">
              </el-input>
            </el-form-item>
          </div>
        </el-form>
        <el-form :model="editModbusClient" inline class="addform"
          v-if="editProtocol.indexOf('lient')>=0 || editProtocol.indexOf('ver')>=0" style="height:auto;">
          <el-form-item class="formline_1" label="Server_IP:" :label-width="formLabelWidth">
            <el-input class="inpu" v-model="editModbusClient.server_ip" placeholder="输入Server IP地址"></el-input>
          </el-form-item>
          <el-form-item class="formline_1" label="Server_Port:" label-width="96px">
            <el-input class="slaveInpu_2" v-model="editModbusClient.server_port" placeholder="输入Server端口号">
            </el-input>
          </el-form-item><br>
          <el-form-item label="轮询周期:" :label-width="formLabelWidth2" class="formline_1" style="height:1.2rem;">
            <el-input v-model="editModbusClient.poll_cycle" class="slaveInpu_2" type="number" min="0" step="10">
            </el-input>
            <div class="tip_1">单位:s(秒)</div>
          </el-form-item>
          <el-form-item label="指令间隔:" :label-width="formLabelWidth2" class="formline_1" style="height:1.2rem;">
            <el-input v-model="editModbusClient.poll_interval" class="slaveInpu_2" type="number" min="10" step="10">
            </el-input>
            <div class="tip_1">单位:ms(毫秒)</div>
          </el-form-item>
          <el-form-item label="超时时长:" :label-width="formLabelWidth2" class="formline_1" style="height:1.2rem;">
            <el-input v-model="editModbusClient.response_timeout" class="slaveInpu_2" type="number" min="1000"
              step="500">
            </el-input>
            <div class="tip_1">单位:ms(毫秒)</div>
          </el-form-item><br>
          <el-form-item label="4区16位写功能选择:" :label-width="formLabelWidth2" class="formline_1">
            <!-- <el-input v-model="modbusMaster.write16_cmd" class="inpu"></el-input> -->
            <el-select v-model="editModbusClient.write16_cmd" class="slaveInpu_2">
              <el-option v-for="item in cmds_16" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="16位整数解码顺序:" :label-width="formLabelWidth2" class="formline_1">
            <el-select v-model="editModbusClient.int16_order" class="slaveInpu_2">
              <el-option v-for="item in orders_16" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="32位整数解码顺序:" :label-width="formLabelWidth2" class="formline_1">
            <el-select v-model="editModbusClient.int32_order" class="slaveInpu_2">
              <el-option v-for="item in orders_32" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item><br>
          <el-form-item label="32位浮点数解码顺序:" :label-width="formLabelWidth2" class="formline_1">
            <el-select v-model="editModbusClient.float_order" class="slaveInpu_2">
              <el-option v-for="item in orders_32" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="64位整数解码顺序:" :label-width="formLabelWidth2" class="formline_1">
            <el-select v-model="editModbusClient.int64_order" class="slaveInpu_2">
              <el-option v-for="item in orders_64" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="64位浮点数解码顺序:" :label-width="formLabelWidth2" class="formline_1">
            <el-select v-model="editModbusClient.double_order" class="slaveInpu_2">
              <el-option v-for="item in orders_64" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item><br>
          <!-- <el-form-item label="CRC检验方式:" :label-width="formLabelWidth2" class="formline_1">
						<el-select v-model="editModbusClient.crc_mode" placeholder="CRC检验方式" class="slaveInpu_2">
							<el-option v-for="item in crc_modes" :key="item.value" :value="item.value"
								:label="item.label">
							</el-option>
						</el-select>
					</el-form-item> -->
          <el-form-item label="最大采集长度:" :label-width="formLabelWidth2" class="formline_1">
            <el-input v-model="editModbusClient.max_length" class="slaveInpu_2" type="number" max="125" step="5">
            </el-input>
            <span class="tip_1">最大值:125</span>
          </el-form-item>
          <div v-if="editModbusClient.state_reg"
            style="border-top:1px dashed #ccc;margin-top:0.1rem;padding-top:0.1rem;">
            <div class="tip_1" style="width:100%;color:red;padding-left:1rem;margin-bottom:0.2rem;font-size:0.3rem;">
              注：以下为状态寄存器功能，需要固件版本的支持,最低版本V5.1.0,如不确定版本号,请不要使用!</div>
            <el-form-item label="下发频率:" :label-width="formLabelWidth2" class="formline_1">
              <el-input v-model="editModbusClient.state_reg.push_interval" class="slaveInpu_2" type="number" min="60"
                step="10">
              </el-input>
              <span class="tip_1">单位:s(秒),最低60s</span>
            </el-form-item><br>
            <el-form-item label="心跳使能:" :label-width="formLabelWidth2" class="formline_1">
              <el-switch v-model="editModbusClient.state_reg.ping_enable" :width="stateWidth" class="demo"
                style="display:inline-block;vertical-align:top;" active-color="#13ce66" inactive-color="#ccc"
                active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
              </el-switch>
            </el-form-item>
            <el-form-item label="心跳地址:" :label-width="formLabelWidth2" class="formline_1">
              <el-input v-model="editModbusClient.state_reg.ping_address" class="slaveInpu_2" placeholder="">
              </el-input>
            </el-form-item><br>
            <el-form-item label="状态使能:" :label-width="formLabelWidth2" class="formline_1">
              <el-switch v-model="editModbusClient.state_reg.state_enable" :width="stateWidth" class="demo"
                style="display:inline-block;vertical-align:top;" active-color="#13ce66" inactive-color="#ccc"
                active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
              </el-switch>
            </el-form-item>
            <el-form-item label="状态地址:" :label-width="formLabelWidth2" class="formline_1">
              <el-input v-model="editModbusClient.state_reg.state_address" class="slaveInpu_2" placeholder="">
              </el-input>
            </el-form-item>
          </div>
        </el-form>

        <el-form :model="editLocalSlave" inline class="addform" v-if="editProtocol=='modbus'" style="height:auto;">
          <el-form-item label="Ethernet_0使能:" :label-width="formLabelWidth2" class="formline_1">
            <el-switch v-model="editLocalSlave.ethernet_0" :width="stateWidth" class="demo"
              style="display:inline-block;vertical-align:top;" active-color="#13ce66" inactive-color="#ccc"
              active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
            </el-switch>
          </el-form-item>
          <el-form-item label="RS485_0使能:" :label-width="formLabelWidth" class="formline_1">
            <el-switch v-model="editLocalSlave.rs485_0" :width="stateWidth" class="demo"
              style="display:inline-block;vertical-align:top;" active-color="#13ce66" inactive-color="#ccc"
              active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
            </el-switch>
          </el-form-item>
          <el-form-item label="RS485_1使能:" :label-width="formLabelWidth" class="formline_1">
            <el-switch v-model="editLocalSlave.rs485_1" :width="stateWidth" class="demo"
              style="display:inline-block;vertical-align:top;" active-color="#13ce66" inactive-color="#ccc"
              active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
            </el-switch>
          </el-form-item><br>
          <el-form-item label="RS485_2使能:" :label-width="formLabelWidth2" class="formline_1">
            <el-switch v-model="editLocalSlave.rs485_2" :width="stateWidth" class="demo"
              style="display:inline-block;vertical-align:top;" active-color="#13ce66" inactive-color="#ccc"
              active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
            </el-switch>
          </el-form-item>
          <el-form-item label="RS232_0使能:" :label-width="formLabelWidth" class="formline_1">
            <el-switch v-model="editLocalSlave.rs232_0" :width="stateWidth" class="demo"
              style="display:inline-block;vertical-align:top;" active-color="#13ce66" inactive-color="#ccc"
              active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
            </el-switch>
          </el-form-item>
          <el-form-item label="响应延时(秒):" :label-width="formLabelWidth" class="formline_1">
            <el-input v-model="editLocalSlave.response_delay" class="slaveInpu_2" placeholder="默认为10秒">
            </el-input>
          </el-form-item>
          <div v-if="editLocalSlave.state_reg" style="border-top:1px dashed #ccc;margin-top:0.1rem;padding-top:0.1rem;">
            <div class="tip_1" style="width:100%;color:red;padding-left:0.6rem;margin-bottom:0.2rem;font-size:0.3rem;">
              注：以下为状态寄存器功能，需要固件版本的支持,最低版本V5.1.0,如不确定版本号,请不要使用!</div>
            <el-form-item label="下发频率:" :label-width="formLabelWidth2" class="formline_1">
              <el-input v-model="editLocalSlave.state_reg.push_interval" class="slaveInpu_2" type="number" min="60"
                step="10">
              </el-input>
              <span class="tip_1">单位:s(秒),最低60s</span>
            </el-form-item><br>
            <el-form-item label="心跳使能:" :label-width="formLabelWidth2" class="formline_1">
              <el-switch v-model="editLocalSlave.state_reg.ping_enable" :width="stateWidth" class="demo"
                style="display:inline-block;vertical-align:top;" active-color="#13ce66" inactive-color="#ccc"
                active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
              </el-switch>
            </el-form-item>
            <el-form-item label="心跳地址:" :label-width="formLabelWidth" class="formline_1">
              <el-input v-model="editLocalSlave.state_reg.ping_address" class="slaveInpu_2" placeholder="">
              </el-input>
            </el-form-item><br>
            <el-form-item label="状态使能:" :label-width="formLabelWidth2" class="formline_1">
              <el-switch v-model="editLocalSlave.state_reg.state_enable" :width="stateWidth" class="demo"
                style="display:inline-block;vertical-align:top;" active-color="#13ce66" inactive-color="#ccc"
                active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
              </el-switch>
            </el-form-item>
            <el-form-item label="状态地址:" :label-width="formLabelWidth" class="formline_1">
              <el-input v-model="editLocalSlave.state_reg.state_address" class="slaveInpu_2" placeholder="">
              </el-input>
            </el-form-item>
          </div>
        </el-form>
        <el-form :model="editS7_200_ppi" inline class="addform"
          v-if="editProtocol.indexOf('pi')>=0 || editProtocol.indexOf('rogram')>=0" style="height:auto;">
          <el-form-item v-if="editProtocol.indexOf('rogram')>=0" label="PLC类型:" :label-width="formLabelWidth"
            class="formline_1" style="height:1.2rem;">
            <el-select v-model="editS7_200_ppi.plc_type" placeholder="PLC类型选择" class="slaveInpu_2">
              <el-option v-for="item in protocols_PLC" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item><br>
          <el-form-item label="轮询周期:" :label-width="formLabelWidth" class="formline_1" style="height:1.2rem;">
            <el-input v-model="editS7_200_ppi.poll_cycle" class="slaveInpu_2" type="number" min="0" step="10">
            </el-input>
            <div class="tip_1">单位:s(秒)</div>
          </el-form-item>
          <el-form-item label="指令间隔:" :label-width="formLabelWidth" class="formline_1" style="height:1.2rem;">
            <el-input v-model="editS7_200_ppi.poll_interval" class="slaveInpu_2" type="number" min="10" step="10">
            </el-input>
            <div class="tip_1">单位:ms(毫秒)</div>
          </el-form-item>
          <el-form-item label="超时时长:" :label-width="formLabelWidth" class="formline_1" style="height:1.2rem;">
            <el-input v-model="editS7_200_ppi.response_timeout" class="slaveInpu_2" type="number" min="1000" step="500">
            </el-input>
            <div class="tip_1">单位:ms(毫秒)</div>
          </el-form-item>
          <div v-if="editS7_200_ppi.state_reg" style="border-top:1px dashed #ccc;margin-top:0.1rem;padding-top:0.1rem;">
            <div class="tip_1" style="width:100%;color:red;padding-left:0.8rem;margin-bottom:0.2rem;font-size:0.3rem;">
              注：以下为状态寄存器功能，需要固件版本的支持,最低版本V5.1.0,如不确定版本号,请不要使用!</div>
            <el-form-item label="下发频率:" :label-width="formLabelWidth" class="formline_1">
              <el-input v-model="editS7_200_ppi.state_reg.push_interval" class="slaveInpu_2" type="number" min="60"
                step="10">
              </el-input>
              <span class="tip_1">单位:s(秒),最低60s</span>
            </el-form-item><br>
            <el-form-item label="心跳使能:" :label-width="formLabelWidth" class="formline_1">
              <el-switch v-model="editS7_200_ppi.state_reg.ping_enable" :width="stateWidth" class="demo"
                style="display:inline-block;vertical-align:top;" active-color="#13ce66" inactive-color="#ccc"
                active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
              </el-switch>
            </el-form-item>
            <el-form-item label="心跳地址:" :label-width="formLabelWidth" class="formline_1">
              <el-input v-model="editS7_200_ppi.state_reg.ping_address" class="slaveInpu_2" placeholder="">
              </el-input>
            </el-form-item><br>
            <el-form-item label="状态使能:" :label-width="formLabelWidth" class="formline_1">
              <el-switch v-model="editS7_200_ppi.state_reg.state_enable" :width="stateWidth" class="demo"
                style="display:inline-block;vertical-align:top;" active-color="#13ce66" inactive-color="#ccc"
                active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
              </el-switch>
            </el-form-item>
            <el-form-item label="状态地址:" :label-width="formLabelWidth" class="formline_1">
              <el-input v-model="editS7_200_ppi.state_reg.state_address" class="slaveInpu_2" placeholder="">
              </el-input>
            </el-form-item>
          </div>
        </el-form>
        <el-form :model="editDL_T645" inline class="addform" v-if="editProtocol.indexOf('645')>=0" style="height:auto;">
          <el-form-item label="轮询周期:" :label-width="formLabelWidth" class="formline_1" style="height:1.2rem;">
            <el-input v-model="editDL_T645.poll_cycle" class="slaveInpu_2" type="number" min="0" step="10">
            </el-input>
            <div class="tip_1">单位:s(秒)</div>
          </el-form-item>
          <el-form-item label="指令间隔:" :label-width="formLabelWidth" class="formline_1" style="height:1.2rem;">
            <el-input v-model="editDL_T645.poll_interval" class="slaveInpu_2" type="number" min="10" step="10">
            </el-input>
            <div class="tip_1">单位:ms(毫秒)</div>
          </el-form-item>
          <el-form-item label="超时时长:" :label-width="formLabelWidth" class="formline_1" style="height:1.2rem;">
            <el-input v-model="editDL_T645.response_timeout" class="slaveInpu_2" type="number" min="1000" step="500">
            </el-input>
            <div class="tip_1">单位:ms(毫秒)</div>
          </el-form-item>
        </el-form>
        <el-form :model="editS7_1200_1500" inline class="addform"
          v-if="editProtocol.indexOf('mart')>=0 || editProtocol.indexOf('1200')>=0 || editProtocol.indexOf('1500')>=0 || editProtocol.indexOf('300')>=0 || editProtocol.toLowerCase()=='s7_200'"
          style="height:auto;">
          <el-form-item class="formline_1" label="PLC IP:" :label-width="formLabelWidth">
            <el-input class="inpu" v-model="editS7_1200_1500.server_ip" placeholder="输入PLC IP地址"></el-input>
            <span class="tip_1" style="margin-left:0.8rem;">PLC端口固定为102，不可更改</span>
          </el-form-item>
          <el-form-item class="formline_1" label="PLC端口:" :label-width="formLabelWidth" v-show="false">
            <el-input class="inpu_2" v-model="editS7_1200_1500.server_port" placeholder="输入PLC端口号">
            </el-input>
          </el-form-item>
          <br>
          <el-form-item label="轮询周期:" :label-width="formLabelWidth" class="formline_1" style="height:1.2rem;">
            <el-input v-model="editS7_1200_1500.poll_cycle" class="slaveInpu_2" type="number" min="0" step="10">
            </el-input>
            <div class="tip_1">单位:s(秒)</div>
          </el-form-item>
          <el-form-item label="指令间隔:" :label-width="formLabelWidth" class="formline_1" style="height:1.2rem;">
            <el-input v-model="editS7_1200_1500.poll_interval" class="slaveInpu_2" type="number" min="10" step="10">
            </el-input>
            <div class="tip_1">单位:ms(毫秒)</div>
          </el-form-item>
          <el-form-item label="超时时长:" :label-width="formLabelWidth" class="formline_1" style="height:1.2rem;">
            <el-input v-model="editS7_1200_1500.response_timeout" class="slaveInpu_2" type="number" min="1000"
              step="500">
            </el-input>
            <div class="tip_1">单位:ms(毫秒)</div>
          </el-form-item><br>
          <el-form-item label="机架号:" :label-width="formLabelWidth" class="formline_1">
            <el-input v-model="editS7_1200_1500.rack_num" class="slaveInpu_2" placeholder="输入机架号">
            </el-input>
          </el-form-item>
          <el-form-item label="槽号:" :label-width="formLabelWidth" class="formline_1">
            <el-input v-model="editS7_1200_1500.slot_num" class="slaveInpu_2" placeholder="输入槽号"></el-input>
          </el-form-item>
          <div v-if="editS7_1200_1500.state_reg"
            style="border-top:1px dashed #ccc;margin-top:0.1rem;padding-top:0.1rem;">
            <div class="tip_1" style="width:100%;color:red;padding-left:0.7rem;margin-bottom:0.2rem;font-size:0.3rem;">
              注：以下为状态寄存器功能，需要固件版本的支持,最低版本V5.1.0,如不确定版本号,请不要使用!</div>
            <el-form-item label="下发频率:" :label-width="formLabelWidth" class="formline_1">
              <el-input v-model="editS7_1200_1500.state_reg.push_interval" class="slaveInpu_2" type="number" min="60"
                step="10">
              </el-input>
              <span class="tip_1">单位:s(秒),最低60s</span>
            </el-form-item><br>
            <el-form-item label="心跳使能:" :label-width="formLabelWidth" class="formline_1">
              <el-switch v-model="editS7_1200_1500.state_reg.ping_enable" :width="stateWidth" class="demo"
                style="display:inline-block;vertical-align:top;" active-color="#13ce66" inactive-color="#ccc"
                active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
              </el-switch>
            </el-form-item>
            <el-form-item label="心跳地址:" :label-width="formLabelWidth" class="formline_1">
              <el-input v-model="editS7_1200_1500.state_reg.ping_address" class="slaveInpu_2" placeholder="">
              </el-input>
            </el-form-item><br>
            <el-form-item label="状态使能:" :label-width="formLabelWidth" class="formline_1">
              <el-switch v-model="editS7_1200_1500.state_reg.state_enable" :width="stateWidth" class="demo"
                style="display:inline-block;vertical-align:top;" active-color="#13ce66" inactive-color="#ccc"
                active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
              </el-switch>
            </el-form-item>
            <el-form-item label="状态地址:" :label-width="formLabelWidth" class="formline_1">
              <el-input v-model="editS7_1200_1500.state_reg.state_address" class="slaveInpu_2" placeholder="">
              </el-input>
            </el-form-item>
          </div>
        </el-form>
        <el-form :model="editFx_serial_port" inline class="addform" v-if="editProtocol.indexOf('erial')>=0"
          style="height:auto;">
          <el-form-item label="PLC类型:" :label-width="formLabelWidth" class="formline_1" style="height:1.2rem;">
            <el-select v-model="editFx_serial_port.plc_type" placeholder="PLC类型选择" class="slaveInpu_2">
              <el-option v-for="item in protocols_PLC" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="协议格式:" :label-width="formLabelWidth" class="formline_1">
            <el-select v-model="editFx_serial_port.protocol_format" class="slaveInpu_2">
              <el-option v-for="item in famtterFxs" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="是否效验:" :label-width="formLabelWidth" class="formline_1">
            <el-select v-model="editFx_serial_port.is_check" class="slaveInpu_2">
              <el-option v-for="item in checkFxs" :key="item.value" :value="item.value" :label="item.label">
              </el-option>
            </el-select>
          </el-form-item><br>
          <el-form-item label="轮询周期:" :label-width="formLabelWidth" class="formline_1"
            style="height:1.2rem;margin-top:-0.4rem;">
            <el-input v-model="editFx_serial_port.poll_cycle" class="slaveInpu_2" type="number" min="0" step="10">
            </el-input>
            <div class="tip_1">单位:s(秒)</div>
          </el-form-item>
          <el-form-item label="指令间隔:" :label-width="formLabelWidth" class="formline_1"
            style="height:1.2rem;margin-top:-0.4rem;">
            <el-input v-model="editFx_serial_port.poll_interval" class="slaveInpu_2" type="number" min="10" step="10">
            </el-input>
            <div class="tip_1">单位:ms(毫秒)</div>
          </el-form-item>
          <el-form-item label="超时时长:" :label-width="formLabelWidth" class="formline_1"
            style="height:1.2rem;margin-top:-0.4rem;">
            <el-input v-model="editFx_serial_port.response_timeout" class="slaveInpu_2" type="number" min="1000"
              step="500">
            </el-input>
            <div class="tip_1">单位:ms(毫秒)</div>
          </el-form-item>

          <div v-if="editFx_serial_port.state_reg"
            style="border-top:1px dashed #ccc;margin-top:0.1rem;padding-top:0.1rem;">
            <div class="tip_1" style="width:100%;color:red;padding-left:0.7rem;margin-bottom:0.2rem;font-size:0.3rem;">
              注：以下为状态寄存器功能，需要固件版本的支持,最低版本V5.1.0,如不确定版本号,请不要使用!</div>
            <el-form-item label="下发频率:" :label-width="formLabelWidth" class="formline_1">
              <el-input v-model="editFx_serial_port.state_reg.push_interval" class="slaveInpu_2" type="number" min="60"
                step="10">
              </el-input>
              <span class="tip_1">单位:s(秒),最低60s</span>
            </el-form-item><br>
            <el-form-item label="心跳使能:" :label-width="formLabelWidth" class="formline_1">
              <el-switch v-model="editFx_serial_port.state_reg.ping_enable" :width="stateWidth" class="demo"
                style="display:inline-block;vertical-align:top;" active-color="#13ce66" inactive-color="#ccc"
                active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
              </el-switch>
            </el-form-item>
            <el-form-item label="心跳地址:" :label-width="formLabelWidth" class="formline_1">
              <el-input v-model="editFx_serial_port.state_reg.ping_address" class="slaveInpu_2" placeholder="">
              </el-input>
            </el-form-item><br>
            <el-form-item label="状态使能:" :label-width="formLabelWidth" class="formline_1">
              <el-switch v-model="editFx_serial_port.state_reg.state_enable" :width="stateWidth" class="demo"
                style="display:inline-block;vertical-align:top;" active-color="#13ce66" inactive-color="#ccc"
                active-text="开" inactive-text="关" :active-value="one" :inactive-value="zero">
              </el-switch>
            </el-form-item>
            <el-form-item label="状态地址:" :label-width="formLabelWidth" class="formline_1">
              <el-input v-model="editFx_serial_port.state_reg.state_address" class="slaveInpu_2" placeholder="">
              </el-input>
            </el-form-item>
          </div>

        </el-form>

      </div>
      <div style="text-align: right;">
        <el-button size="small" @click="editSlaveFormVisible = false">取 消</el-button>
        <el-button type="primary" size="small" @click="modifySlave">确 定</el-button>
      </div>
    </el-dialog>
    <el-dialog :visible="dialogInfoVisible" v-el-dialog-drag v-el-dialog-drag-width width="30%" append-to-body
      top="200px" class="dial" :show-close="close">
      <div class="toptit">
        <span>状态寄存器参数说明</span>
        <span style="float:right;cursor: pointer;" @click="dialogInfoVisible=false">关闭</span>
      </div>
      <div class="infocontent">
        <!-- <h2 style="width:100%;text-align: center;margin-top:0.2rem;"></h2><br> -->
        <p>
        <h4>频率与使能：</h4>
        1.根据下发频率(时间间隔)定时给心跳地址定时发送0/1跳变,使能确定其是否使用;<br>
        2.根据下发频率(时间间隔)定时给状态地址定时发送状态码,1表示正常,0表示未初始化,2表示联网异常,使能确定其是否使用;<br>
        <h4>心跳地址和状态地址分区默认规则：</h4>
        1.Modbus系列协议默认为4区地址;<br>
        2.S7 200系列协议默认为VW区地址;<br>
        3.三菱FX系列协议默认为D区地址;<br>
        4.S7 1200协议和S7 1500协议默认为DB区地址;</p>
      </div>
    </el-dialog>

  </div>
</template>

<script>
  import ChannelInfo from '../templates/ChannelInfo.vue';
  import SlaveInfo from '../templates/SlaveInfo.vue';
  import configData from '../common.js';
  export default {
    name: 'slaveRead',
    data() {
      return {
        one: 1,
        zero: 0,
        loading: true,
        sendLoading: false,
        operType: '',
        deviceData: {},
        formLabelWidth2: '3.6rem',
        formLabelWidth: '2.2rem',
        showChannel: true,
        close: false,
        canSet: false,
        addFormVisible: false,
        editFormVisible: false,
        dialogInfoVisible: false,
        stateWidth: 60,
        showNameAddr: false,
        channelSlaveData: [],
        slaveSensorData: [],
        channelSlaves: [],
        treeSlaveId: 0,
        channelTip: '(默认显示第一个端口的参数,点击相应端口可切换)',
        channelInfo: {
          channel_type: '',
          channel_mode: 0,
          channel_config: {
            baud_rate: 9600, // 波特率为 9600
            data_bits: 8, // 数据位为 8
            stop_bits: 1, // 停止位为 1
            parity: 0
          },
        },
        slaveTip: '(点击相应子设备可切换)',
        slaveInfo: {
          slave_protocol: '',
          channel_type: ''
        },
        styleObj: {
          'line-height': '1rem'
        },
        protocols: [],
        protocols_485: configData.protocols_485,
        protocols_PLC: configData.protocols_PLC,
        protocols_ethernet: configData.protocols_ethernet,
        protocols_local: configData.protocols_local,
        channels: configData.channels,
        baudRates: configData.baudRates,
        dataBits: [{
            value: 8,
            label: 8
          },
          {
            value: 7,
            label: 7
          }
        ],
        stopBits: [{
          value: 1,
          label: 1
        }, {
          value: 2,
          label: 2
        }],
        parities: configData.parities,
        speeds: configData.speeds,
        channelForm: {
          channel_type: 'rs485_0',
          channel_mode: 0,
          channel_config: {}
          //slave_protocol: "modbus_rtu_master",
          //report_interval:60
        },
        editChannelForm: {
          id: 0,
          channel_mode: 0,
          channel_type: '',
          //report_interval:60,
          rs485Config: {},
          comConfig: {},
          ethernetConfig: {},
          loraConfig: {},
          zigbeeConfig: {},
          localConfig: {},
          channel_config: {}
          //slave_protocol: "",
        },
        rs485Config: configData.rs485Config,
        ethernetConfig: configData.ethernetConfig,
        loraConfig: configData.loraConfig,
        zigbeeConfig: configData.zigbeeConfig,
        localConfig: configData.localConfig,
        comConfig: configData.comConfig,
        timeoutOptions: configData.timeoutOptions,
        channelModes: [{
            value: 0,
            label: '边缘采集'
          },
          {
            value: 1,
            label: '数据透传'
          }
        ],
        channelData: [],
        screenWidth: 1920,
        //子设备添加编辑相关数据点
        protocol: '',
        addSlaveForm: {
          name: '子设备1', //
          num: '',
          template: 0,
          slave_protocol: '',
          channel: '',
          slave_addr: 1 //西蒙子2，modbus为1
        },
        channelWord: '',
        //端口的简写：
        shortChannel: '',
        //协议的简写
        shortProtocol: '',
        slaveChannels: [],
        templateSensor: {},
        addSlaveFormVisible: false,
        editSlaveFormVisible: false,
        moulds: [],
        //modbus_master
        modbusMaster: configData.modbusMaster,
        modbusClient: configData.modbusClient,
        modbusSlave: configData.modbusSlave,
        localSlave: configData.localSlave,
        s7_200_ppi: configData.s7_200_ppi,
        dl_T645: configData.dl_T645,
        //s7_200_smart，s7-1200,s7-1500配置参数相同
        s7_1200_1500: configData.s7_1200_1500,
        //三菱fx串口系列协议参数
        fx_serial_port: configData.fx_serial_port,
        cmds_16: configData.cmds_16,
        orders_16: configData.orders_16,
        orders_32: configData.orders_32,
        orders_64: configData.orders_64,
        crc_modes: configData.crc_modes,
        editProtocol: '',
        editSlaveForm: {
          template: 0,
          name: '',
          num: '',
          sensors_count: 0,
          channel: '',
          slave_addr: ''
        },
        editModbusMaster: {
          ...configData.modbusMaster
        },
        editModbusClient: {
          ...configData.modbusClient
        },
        editModbusSlave: {
          ...configData.modbusSlave
        },
        editLocalSlave: {
          response_delay: 10 //响应延时时间
        },
        editS7_200_ppi: {
          ...configData.s7_200_ppi
        },
        editDL_T645: {
          ...configData.dl_T645
        },
        //s7-200_smart,s7-1200,s7-1500配置参数相同
        editS7_1200_1500: {
          ...configData.s7_1200_1500
        },
        //三菱fx串口协议参数
        editFx_serial_port: {
          ...configData.fx_serial_port
        },
        infoShow: 'channel',
        defaultChannelId: 0,
        defaultChannelLabel: '',
        //以下是数据点相关
        showMao: '',
        dialogFormVisible_4: false,
        copyTem: {
          template_name: '',
          remark: ''
        },
        whileIfs: configData.whileIfs,
        waterMarks: configData.waterMarks,
        baseurl: this.$baseurl,
        //more: true,
        //more_2: true,
        dialogFormVisible_2: false,
        dialogFormVisible_3: false,
        addForm: {
          boxNum: 1,
          //t645标识4个
          sign_0: '00',
          sign_1: '00',
          sign_2: '00',
          sign_3: '00',
          data_channel: "",
          first_key: 0,
          sensor_total: 1,
          step: 1,
          sensor_name: '',
          show_type: 1,
          value_type: 0,
          value_key: '',
          //read_write: 1, //1只读，2读写
          save_type: 2, //1存储，2不存储，3变化存储
          data_key: '',
          unit: '',
          //standard_max:'',
          //standard_min:'',
          min_value: 0,
          max_value: 65535,
          mark: 0,
          //ext_vars:'',
          report_type: 0,
          decimals: 0,
          list_order: 0,
          magnification: 1,
          value_offset: 0,
          threshold: 1,
          slave_name: '',
          slave_protocol: '',
          channel_type: '',
          visible: false,
          icon: 'static/images/icon/icon1.png'
        },
        dataChannels: [],
        nativeKey: '',
        //modbus系列数据通道是一样的；
        addSensor_modbus: configData.addSensor_modbus,
        //s7_200_smart和s7_200_ppi数据通道是一样的；
        addSensor_s7200: configData.addSensor_s7200,
        //s7_1200和s7_1500数据通道是一样的；
        addSensor_1200_1500: configData.addSensor_1200_1500,
        //两个三菱fx协议数据通道是一样的；
        addSensor_mitsubishi_fx: configData.addSensor_mitsubishi_fx,
        editForm: {
          sensor_name: '',
          show_type: 1,
          //read_write: 1, //1只读，2读写
          save_type: 2, //1存储，2不存储，3变化存储
          data_key: '',
          value_key: '',
          value_type: 0,
          magnification: 1,
          value_offset: 0,
          threshold: 1,
          unit: '',
          //standard_max:'',
          //standard_min:'',
          min_value: 0,
          max_value: 65535,
          mark: 0,
          //ext_vars:'',
          report_type: 0,
          decimals: 0,
          list_order: 0,
          visible: false,
          icon: 'static/images/icon/icon1.png'
        },
        dialogFormVisible: false,
        domains: [],
        domains2: [],
        //数据属性选项
        reportTypes: configData.reportTypes,
        //存储选项
        saves: configData.saves,
        //读写/显示选项
        options: configData.options,
        //小数点选项
        points: configData.points,
        //三菱fx协议参数协议格式选项
        famtterFxs: configData.famtterFxs,
        //三菱fx协议参数是否效验选项
        checkFxs: configData.checkFxs,
        //i,q区数值类型一样
        valueTypes_IQ: configData.valueTypes_IQ,
        //m,v,db区数值类型一样
        valueTypes_MV: configData.valueTypes_MV,
        //modBus的0区1区数值类型只有布尔型
        valueTypes_01: configData.valueTypes_01,
        //modBus的3区4区数值类型
        valueTypes_34: configData.valueTypes_34,
        //T645协议数值类型
        valueTypes_T645: configData.valueTypes_T645,
        //两个三菱fx协议D区数值类型
        valueTypes_Fx_D: configData.valueTypes_Fx_D,
        allSlaves: [],
        allSlavesId: [],
        valueTypes: [],
        //版本号转小数的方法
        //versionToFloat:configData.versionToFloat,
        setForm: {
          template_name: 0
        },
        moulds: [{
          value: 0,
          label: '无'
        }]
      }
    },

    components: {
      ChannelInfo,
      SlaveInfo
    },

    created() {
      localStorage.removeItem('operType');
      this.deviceData = JSON.parse(localStorage.getItem('deviceData'));
      if (this.deviceData.version == 3) {
        this.channels = configData.channels_53;
      }
      this.readSet();
    },

    mounted() {
      this.screenWidth = window.screen.width || 1920;
      if (this.screenWidth <= 1366) {
        this.formLabelWidth2 = "4.2rem";
        this.formLabelWidth = "3rem";
      }
      this.getTemplate();

    },

    beforeRouteEnter(to, from, next) {
      next(vm => {
        if (from.name == "slave") {
          vm.repeatRead();
          //vm.$router.go(0);
          // vm.readSet();
          // vm.$forceUpdate()
        }
      })
    },

    methods: {
      //页面整体相关函数
      returnTop() {
        //scrollIntoView为原生方法，调用方式为 element.scrollIntoView() 参数默认为true。
        //参数为true时调用该函数，页面（或容器）发生滚动，使element的顶部与视图（容器）顶部对齐；
        //参数为false时，使element的底部与视图（容器）底部对齐。
        // 页面（容器）可滚动时才有用！
        document.querySelector("#topMao").scrollIntoView(true);
      },

      returnBottom() {
        document.querySelector("#bottomMao").scrollIntoView(false);
      },

      repeatRead() {
        window.location.reload();
      },


      //滚动条滚动事件
      changeScroll(event) {
        if (event.target.scrollTop >= 500) {
          this.showMao = 'goTop';
        } else {
          this.showMao = 'goBottom';
        }
      },

      goBack() {
        this.$router.push({
          name: 'slave',
          path: '/slave'
        });
      },

      goList() {
        this.$router.push({
          name: 'device',
          path: '/device'
        });
      },

      readSet() {
        this.loading = true;
        this.channelSlaveData = [];
        this.slaveSensorData = [];
        this.$http({
          method: 'post',
          url: 'api/equip/readConfig',
          data: {
            'id': this.deviceData.id

          }
        }).then(res => {
          if (res && res.data.result == "success") {
            this.channelSlaveData = res.data.data.tree;
            this.slaveSensorData = res.data.data.vars;
            for (let i = 0, len = res.data.data.vars.length; i < len; i++) {
              this.slaveSensorData[i].sensors = this.getSensor(res.data.data.vars[i].sensors, res
                .data.data.vars[i].slave_name);
              for (let n = 0, len2 = res.data.data.vars[i].sensors.length; n < len2; n++) {
                //读的没有icon,追加默认icon
                this.slaveSensorData[i].sensors[n].icon = "static/images/icon/icon1.png";
                this.slaveSensorData[i].sensors[n].channel_type = this.slaveSensorData[i]
                  .channel_type;
                this.slaveSensorData[i].sensors[n].slave_protocol = this.slaveSensorData[i]
                  .slave_protocol;
                //
              }
            }
            this.getChannelTree();
            this.$message({
              message: '恭喜,读取配置成功!',
              type: 'success',
              offset: 300,
              duration: 2000,
              center: true
            });
            this.loading = false;

          } else {
            this.loading = false;
          }
        }).catch(error => {
          this.loading = false;
          console.log(error);
        });
      },
      //左侧端口和子设备整体相关函数
      getChannelTree() {
        var that = this;
        this.allSlaves = [];
        this.allSlavesId = [];
        this.channelSlaves.length = 0;
        for (let i = 0, len = this.channelSlaveData.length; i < len; i++) {
          let oneChannel = {
            id: that.channelSlaveData[i].label,
            label: that.channelSlaveData[i].label,
            mode: that.channelSlaveData[i].channel_mode,
            index: i + 1,
            channel_config: that.channelSlaveData[i].channel_config,
            children: []
          }
          this.channelSlaves.push(oneChannel);
          for (let n = 0, len2 = this.channelSlaveData[i].children.length; n < len2; n++) {
            this.allSlaves.push(that.channelSlaveData[i].children[n].slave_name);
            this.allSlavesId.push(that.channelSlaveData[i].children[n].slave_no);
            let oneSlave = {
              id: that.channelSlaveData[i].children[n].label,
              label: that.channelSlaveData[i].children[n].label,
              slave_name: that.channelSlaveData[i].children[n].slave_name,
              slave_addr: that.channelSlaveData[i].children[n].slave_addr,
              channel_type: that.channelSlaveData[i].children[n].channel_type,
              slave_no: that.channelSlaveData[i].children[n].slave_no,
              slave_protocol: that.channelSlaveData[i].children[n].slave_protocol,
              sensors_count: that.channelSlaveData[i].children[n].sensors_count,
              slave_config: that.channelSlaveData[i].children[n].slave_config
            }
            this.channelSlaves[i].children.push(oneSlave);
          }

        }
        //默认显示第一个端口的参数；
        this.getChannelInfo(this.channelSlaves[0])
        // console.log(this.channelSlaves);
      },

      edit(node, data) {
        if (node.level == 1) {
          this.modifyChannel(data);
        } else {
          this.preModifySlave(data);
        }
      },

      remove(node, data) {
        //读取的端口不可删除
        //    this.infoShow="channel";
        //    //端口详情函数
        //    this.sureDeleteChannel(data.id);
        // }else{
        if (node.level == 2) {
          //this.infoShow="slave";
          //console.log(data.id);
          //子设备删除函数；
          this.sureDelete(data.id, data.label);
        }
      },

      getInfo(node, data) {
        event.stopImmediatePropagation();
        if (node.level == 1) {
          //端口详情函数
          this.infoShow = "channel";
          this.getChannelInfo(data);
          this.defaultChannelId = data.id;
          this.defaultChannelLabel = this.channelToUpper(data.label);
        } else {
          this.infoShow = "slave";
          this.getSlaveShowInfo(data);
          var content = document.getElementById("slaveBox").offsetTop;
          var slave = document.getElementById(node.label).offsetTop;
          document.getElementById('slaveBox').scrollTop = slave - content - 10;
        }
      },

      hiddenChannel() {
        if (this.showChannel) {
          this.$refs.channel.style.width = 0;
          this.$refs.channel.style.overflow = "hidden";
          this.$refs.slave.style.width = "100%";
          this.showChannel = false;
          // this.$refs.channel.style.overflow="hidden";
        } else {
          this.$refs.channel.style.width = "13%";
          this.$refs.channel.style.overflow = "auto";
          this.$refs.slave.style.width = "86%";
          this.showChannel = true;
        }
      },

      getChannelInfo(data) {
        this.channelInfo.channel_config = data.channel_config;
        this.channelInfo.channel_type = data.label;
        if (this.deviceData.version == 3) {
          this.channelInfo.channel_mode = data.mode;
        }
        if (data.label.indexOf('thernet') == -1 && data.label.indexOf('ocal') == -1) {
          if (data.channel_config.parity == 0) {
            this.channelInfo.channel_config.parity = 'None';
          } else if (data.channel_config.parity == 1) {
            this.channelInfo.channel_config.parity = 'Odd';
          } else if (data.channel_config.parity == 2) {
            this.channelInfo.channel_config.parity = 'Even';
          }
        }
      },

      modifyChannel(row) {
        //this.editChannelForm.id = row.id;
        this.editChannelForm.channel_type = row.id;
        if (this.deviceData.version == 3) {
          this.editChannelForm.channel_mode = row.mode;
        }
        //this.editChannelForm.report_interval = row.report_interval;
        //setTimeout(function(){
        if (this.editChannelForm.channel_type.indexOf('rs') >= 0) {
          //that.protocols=that.protocols_485;
          this.editChannelForm.rs485Config = Object.assign({}, row.channel_config);
        } else if (this.editChannelForm.channel_type.indexOf('com') == 0) {
          this.editChannelForm.comConfig = Object.assign({}, row.channel_config);
        } else if (this.editChannelForm.channel_type.indexOf('thernet') >= 0) {
          //that.protocols=that.protocols_ethernet;
          this.editChannelForm.ethernetConfig = Object.assign({}, row.channel_config);
        } else if (this.editChannelForm.channel_type.indexOf('ora') >= 0) {
          //that.protocols=that.protocols_485;
          this.editChannelForm.loraConfig = Object.assign({}, row.channel_config);
        } else if (this.editChannelForm.channel_type.indexOf('igbee') >= 0) {
          //that.protocols=that.protocols_485;
          this.editChannelForm.zigbeeConfig = Object.assign({}, row.channel_config);
        } else if (this.editChannelForm.channel_type.indexOf('ocal') >= 0) {
          //that.protocols=that.protocols_local;
          this.editChannelForm.localConfig = Object.assign({}, row.channel_config);
        }
        //that.editChannelForm.slave_protocol=row.slave_protocol;
        //},1000);
        this.editFormVisible = true;
      },

      updateChannel() {
        if (this.editChannelForm.channel_type.indexOf('rs') >= 0) {
          this.editChannelForm.channel_config = this.editChannelForm.rs485Config;
        } else if (this.editChannelForm.channel_type.indexOf('com') == 0) {
          this.editChannelForm.channel_config = this.editChannelForm.comConfig;
        } else if (this.editChannelForm.channel_type.indexOf('thernet') >= 0) {
          this.editChannelForm.channel_config = this.editChannelForm.ethernetConfig;
        } else if (this.editChannelForm.channel_type.indexOf('ora') >= 0) {
          this.editChannelForm.channel_config = this.editChannelForm.loraConfig;
        } else if (this.editChannelForm.channel_type.indexOf('igbee') >= 0) {
          this.editChannelForm.channel_config = this.editChannelForm.zigbeeConfig;
        } else if (this.editChannelForm.channel_type.indexOf('ocal') >= 0) {
          this.editChannelForm.channel_config = this.editChannelForm.localConfig;
        }
        for (let i = 0, len = this.channelSlaves.length; i < len; i++) {
          if (this.channelSlaves[i].id == this.editChannelForm.channel_type) {
            if (this.deviceData.version == 3) {
              this.channelSlaves[i].channel_mode = this.editChannelForm.channel_mode;
            }
            this.channelSlaves[i].channel_config = this.editChannelForm.channel_config;
            this.getChannelInfo(this.channelSlaves[i]);
          }
        }
        this.editFormVisible = false;
      },

      getChannel() {
        var that = this;
        this.slaveChannels = [];
        for (let i = 0, len = this.channelSlaves.length; i < len; i++) {
          let channel = {
            value: that.channelSlaves[i].id,
            label: that.channelToUpper(that.channelSlaves[i].label)
            //protocol: res.data.data[i].slave_protocol
          }
          that.slaveChannels.push(channel);
        }
        //this.createDataKey('0x00000',1,2)
      },

      getSlaveShowInfo(data) {
        //console.log(data);
        this.slaveInfo = this.copy(data);
        this.slaveInfo.slave_config = this.copy(data.slave_config);
        switch (Number(data.slave_config.write16_cmd)) {
          case 0:
            this.slaveInfo.slave_config.write16_cmd = '0x06';
            break;
          case 1:
            this.slaveInfo.slave_config.write16_cmd = '0x10';
            break;
        }
        switch (Number(data.slave_config.int16_order)) {
          case 0:
            this.slaveInfo.slave_config.int16_order = 'AB';
            break;
          case 1:
            this.slaveInfo.slave_config.int16_order = 'BA';
            break;
        }
        switch (Number(data.slave_config.crc_mode)) {
          case 0:
            this.slaveInfo.slave_config.crc_mode = 'LH';
            break;
          case 1:
            this.slaveInfo.slave_config.crc_mode = 'HL';
            break;
        }
        switch (Number(data.slave_config.int32_order)) {
          case 0:
            this.slaveInfo.slave_config.int32_order = 'ABCD';
            break;
          case 1:
            this.slaveInfo.slave_config.int32_order = 'CDAB';
            break;
          case 2:
            this.slaveInfo.slave_config.int32_order = 'BADC';
            break;
          case 3:
            this.slaveInfo.slave_config.int32_order = 'DCBA';
            break;
        }
        switch (Number(data.slave_config.float_order)) {
          case 0:
            this.slaveInfo.slave_config.float_order = 'ABCD';
            break;
          case 1:
            this.slaveInfo.slave_config.float_order = 'CDAB';
            break;
          case 2:
            this.slaveInfo.slave_config.float_order = 'BADC';
            break;
          case 3:
            this.slaveInfo.slave_config.float_order = 'DCBA';
            break;
        }
        switch (Number(data.slave_config.int64_order)) {
          case 0:
            this.slaveInfo.slave_config.int64_order = 'ABCDEFGH';
            break;
          case 1:
            this.slaveInfo.slave_config.int64_order = 'GHEFCDAB';
            break;
          case 2:
            this.slaveInfo.slave_config.int64_order = 'BADCFEHG';
            break;
          case 3:
            this.slaveInfo.slave_config.int64_order = 'KGFEDCBA';
            break;
        }
        switch (Number(data.slave_config.double_order)) {
          case 0:
            this.slaveInfo.slave_config.double_order = 'ABCDEFGH';
            break;
          case 1:
            this.slaveInfo.slave_config.double_order = 'GHEFCDAB';
            break;
          case 2:
            this.slaveInfo.slave_config.double_order = 'BADCFEHG';
            break;
          case 3:
            this.slaveInfo.slave_config.double_order = 'KGFEDCBA';
            break;
        }
        this.$forceUpdate();

      },


      //添加子设备相关函数
      preAddSlave() {
        this.getChannel();
        this.addSlaveFormVisible = true;
        this.addSlaveForm.channel = this.defaultChannelId ? this.defaultChannelId : this.slaveChannels[0].value;
        this.addSlaveForm.name = '子设备1';
        //console.log(this.defaultChannelId,this.defaultChannelLabel);
        this.channelWord = this.defaultChannelLabel ? this.defaultChannelLabel : this.slaveChannels[0].label;
        this.addSlaveForm.template = 0;
        //端口的简写：
        this.shortChannel = '';
        //协议的简写
        this.shortProtocol = '';
        //this.addSlaveForm.num = new Date().getTime();
        //console.log(this.slaveChannels);
        if (this.channelWord.indexOf('485') >= 0) {
          this.protocols = this.protocols_485;
          this.shortChannel = "";
        } else if (this.channelWord.indexOf('Com') == 0) {
          this.protocols = this.protocols_485;
          this.shortChannel = "Com";
        } else if (this.channelWord.indexOf('232') >= 0) {
          this.protocols = this.protocols_485;
          this.shortChannel = "232_";
        } else if (this.channelWord.indexOf('thernet') >= 0) {
          this.protocols = this.protocols_ethernet;
          this.shortChannel = "";
        } else if (this.channelWord.indexOf('oRa') >= 0) {
          this.protocols = this.protocols_485;
          this.shortChannel = "LoRa_";
        } else if (this.channelWord.indexOf('igbee') >= 0) {
          this.protocols = this.protocols_485;
          this.shortChannel = "Zig_";
        } else if (this.channelWord.indexOf('ocal') >= 0) {
          this.protocols = this.protocols_local;
          this.shortChannel = "Local";
        }
        this.addSlaveForm.slave_protocol = this.protocols[0].value;
        //第一个协议不会出现T645,所以这里不判断
        if (this.addSlaveForm.slave_protocol.indexOf('s7') >= 0) {
          this.addSlaveForm.slave_addr = 2;
          this.s7_1200_1500.server_ip = "192.168.2.1";
        } else {
          this.addSlaveForm.slave_addr = 1;
        }
        this.changeAddProtocol(this.addSlaveForm.slave_protocol);

      },

      changeAddProtocol(protocol) {
        this.s7_200_ppi.state_reg.ping_address = "VW0";
        this.s7_200_ppi.state_reg.state_address = "VW2";
        this.s7_1200_1500.state_reg.ping_address = "DB1.DB0.0";
        this.s7_1200_1500.state_reg.state_address = "DB1.DB0.1";
        if (this.addSlaveForm.slave_protocol.indexOf('rtu_master') >= 0) {
          this.shortProtocol = 'Slave';
        } else if (this.addSlaveForm.slave_protocol.indexOf('ascii') >= 0) {
          this.shortProtocol = 'Slave';
        } else if (this.addSlaveForm.slave_protocol.indexOf('lient') >= 0) {
          this.shortProtocol = 'Server';
        } else if (this.addSlaveForm.slave_protocol.indexOf('ver') >= 0) {
          this.shortProtocol = 'Server';
        } else if (this.addSlaveForm.slave_protocol == 'modbus') {
          this.shortProtocol = '';
        } else if (this.addSlaveForm.slave_protocol.indexOf('pi') >= 0) {
          this.shortProtocol = 'S7-200PLC';
        } else if (this.addSlaveForm.slave_protocol.indexOf('645_1997') >= 0) {
          this.shortProtocol = '645_97_';
        } else if (this.addSlaveForm.slave_protocol.indexOf('645_2007') >= 0) {
          this.shortProtocol = '645_07_';
        } else if (this.addSlaveForm.slave_protocol.indexOf('rogram') >= 0) {
          this.s7_200_ppi.state_reg.ping_address = "D0000";
          this.s7_200_ppi.state_reg.state_address = "D0001";
          this.shortProtocol = 'Slave';
        } else if (this.addSlaveForm.slave_protocol.indexOf('erial') >= 0) {
          this.shortProtocol = 'Slave';
        } else if (this.addSlaveForm.slave_protocol.indexOf('mart') >= 0) {
          this.s7_1200_1500.state_reg.ping_address = "VW0";
          this.s7_1200_1500.state_reg.state_address = "VW2";
          this.shortProtocol = 'S7-SmartPLC';
        } else if (this.addSlaveForm.slave_protocol.toLowerCase() == 's7_200') {
          this.s7_1200_1500.state_reg.ping_address = "VW0";
          this.s7_1200_1500.state_reg.state_address = "VW2";
          this.shortProtocol = 'S7-200PLC';
        } else if (this.addSlaveForm.slave_protocol.indexOf('1200') >= 0) {
          this.shortProtocol = 'S7-1200PLC';
        } else if (this.addSlaveForm.slave_protocol.indexOf('300') >= 0) {
          this.shortProtocol = 'S7-300/400PLC';
        } else if (this.addSlaveForm.slave_protocol.indexOf('1500') >= 0) {
          this.shortProtocol = 'S7-1500PLC';
        }
        if (this.addSlaveForm.slave_protocol.indexOf('s7') >= 0) {
          this.addSlaveForm.slave_addr = 2;
          this.s7_1200_1500.server_ip = "192.168.2.1";
        } else if (this.addSlaveForm.slave_protocol.indexOf('645') >= 0) {
          this.addSlaveForm.slave_addr = "000000691889";
        } else {
          this.addSlaveForm.slave_addr = 1;
        }
        if (this.channelWord.indexOf('thernet') >= 0) {
          this.addSlaveForm.num = this.shortChannel + this.shortProtocol + '1';
        } else if (this.channelWord.indexOf('ocal') >= 0) {
          this.addSlaveForm.num = this.shortChannel;
        } else if (this.addSlaveForm.slave_protocol.indexOf('645') >= 0) {
          this.addSlaveForm.num = this.shortChannel + this.shortProtocol + this.addSlaveForm.slave_addr.substr(this
            .addSlaveForm.slave_addr.length - 3, 3);
        } else {
          this.addSlaveForm.num = this.shortChannel + this.shortProtocol + this.addSlaveForm.slave_addr;

        }
      },

      changeAddSlaveChannel(channel) {
        //console.log(channel)
        let nowChannel = "";
        for (let i = 0, len = this.slaveChannels.length; i < len; i++) {
          if (this.slaveChannels[i].value == channel) {
            nowChannel = this.slaveChannels[i].label;
            this.channelWord = this.slaveChannels[i].label;
            if (nowChannel.indexOf('485') >= 0) {
              this.protocols = this.protocols_485;
              this.shortChannel = "";
            } else if (nowChannel.indexOf('Com') == 0) {
              this.protocols = this.protocols_485;
              this.shortChannel = "Com";
            } else if (nowChannel.indexOf('232') >= 0) {
              this.protocols = this.protocols_485;
              this.shortChannel = "232_";
            } else if (nowChannel.indexOf('thernet') >= 0) {
              this.protocols = this.protocols_ethernet;
              this.shortChannel = "";
            } else if (nowChannel.indexOf('oRa') >= 0) {
              this.protocols = this.protocols_485;
              this.shortChannel = "LoRa_";
            } else if (nowChannel.indexOf('igbee') >= 0) {
              this.protocols = this.protocols_485;
              this.shortChannel = "Zig_";
            } else if (nowChannel.indexOf('ocal') >= 0) {
              this.protocols = this.protocols_local;
              this.shortChannel = "Local";
            }
            this.addSlaveForm.slave_protocol = this.protocols[0].value;
            //第一个协议不会出现T645,所以这里不判断
            if (this.addSlaveForm.slave_protocol.indexOf('s7') >= 0) {
              this.addSlaveForm.slave_addr = 2;
              this.s7_1200_1500.server_ip = "192.168.2.1";
            } else {
              this.addSlaveForm.slave_addr = 1;
            }
            this.changeAddProtocol(this.addSlaveForm.slave_protocol);
            break;
          }
        }

      },

      changeAddAddr() {
        if (this.channelWord.indexOf('thernet') >= 0) {
          this.addSlaveForm.num = this.shortChannel + this.shortProtocol + '1';
        } else if (this.channelWord.indexOf('ocal') >= 0) {
          this.addSlaveForm.num = this.shortChannel;
        } else if (this.addSlaveForm.slave_protocol.indexOf('645') >= 0) {
          this.addSlaveForm.num = this.shortChannel + this.shortProtocol + this.addSlaveForm.slave_addr.substr(this
            .addSlaveForm.slave_addr.length - 3, 3);
        } else {
          this.addSlaveForm.num = this.shortChannel + this.shortProtocol + this.addSlaveForm.slave_addr;

        }
      },

      argmentInfo() {
        this.dialogInfoVisible = true;
      },

      addSlave() {
        var that = this;
        if (this.allSlaves.indexOf(that.addSlaveForm.name) >= 0) {
          this.$message({
            message: '同一网关下，子设备名称不可重复！',
            type: 'error',
            center: true,
            offset: 300

          })
          return false
        }
        if (this.allSlavesId.indexOf(that.addSlaveForm.num) >= 0) {
          this.$message({
            message: '同一网关下，子设备ID不可重复！',
            type: 'error',
            center: true,
            offset: 300

          })
          return false
        }
        let slaveConfig = {};
        if (this.addSlaveForm.slave_protocol.indexOf('rtu_master') >= 0) {
          slaveConfig = Object.assign({}, that.modbusMaster);
        } else if (this.addSlaveForm.slave_protocol.indexOf('ascii') >= 0) {
          slaveConfig = Object.assign({}, that.modbusMaster);
        } else if (this.addSlaveForm.slave_protocol.indexOf('lient') >= 0) {
          slaveConfig = Object.assign({}, that.modbusClient);
        } else if (this.addSlaveForm.slave_protocol.indexOf('ver') >= 0) {
          slaveConfig = Object.assign({}, that.modbusClient);
        } else if (this.addSlaveForm.slave_protocol == 'modbus') {
          slaveConfig = Object.assign({}, that.localSlave);
        } else if (this.addSlaveForm.slave_protocol.indexOf('pi') >= 0 || this.addSlaveForm.slave_protocol.indexOf(
            'rogram') >= 0) {
          slaveConfig = Object.assign({}, that.s7_200_ppi);
        } else if (this.addSlaveForm.slave_protocol.indexOf('645') >= 0) {
          slaveConfig = Object.assign({}, that.dl_T645);
        } else if (this.addSlaveForm.slave_protocol.indexOf('mart') >= 0 || this.addSlaveForm.slave_protocol
          .indexOf('1200') >= 0 || this.addSlaveForm.slave_protocol.indexOf('1500') >= 0 || this.addSlaveForm
          .slave_protocol.indexOf('300') >= 0 || this.addSlaveForm.slave_protocol.toLowerCase() == 's7_200') {
          slaveConfig = Object.assign({}, that.s7_1200_1500);
        } else if (this.addSlaveForm.slave_protocol.indexOf('erial') >= 0) {
          slaveConfig = Object.assign({}, that.fx_serial_port);
        }

        //console.log(slaveConfig);
        let oneSlave = {
          id: that.addSlaveForm.name,
          label: that.addSlaveForm.name,
          //template_id: that.addSlaveForm.template,
          slave_name: that.addSlaveForm.name,
          slave_protocol: that.addSlaveForm.slave_protocol,
          channel_type: that.addSlaveForm.channel,
          slave_no: that.addSlaveForm.num,
          slave_addr: that.addSlaveForm.slave_addr,
          sensors_count: 0,
          slave_config: slaveConfig
        }
        this.allSlaves.push(that.addSlaveForm.name);
        this.allSlavesId.push(that.addSlaveForm.num);
        for (let i = 0, len = this.channelSlaves.length; i < len; i++) {
          if (this.channelSlaves[i].id == this.addSlaveForm.channel) {
            this.channelSlaves[i].children.push(oneSlave);
          }
        }

        if (this.addSlaveForm.template) {
          this.getTemplateInfo(this.addSlaveForm.template, this.addSlaveForm.name);
          setTimeout(function() {
            for (let l = 0, len3 = that.templateSensor.sensors.length; l < len3; l++) {
              that.templateSensor.sensors[l].channel_type = that.addSlaveForm.channel;
              that.templateSensor.sensors[l].slave_protocol = that.addSlaveForm.slave_protocol;
            }
            that.slaveSensorData.push({
              slave_no: that.addSlaveForm.num,
              slave_name: that.addSlaveForm.name,
              sensors_count: that.templateSensor.sensors.length,
              slave_config: slaveConfig,
              slave_addr: that.addSlaveForm.slave_addr,
              sensors: that.templateSensor.sensors
            })
          }, 1000)
        } else {
          this.slaveSensorData.push({
            slave_no: that.addSlaveForm.num,
            slave_name: that.addSlaveForm.name,
            sensors_count: 0,
            slave_addr: that.addSlaveForm.slave_addr,
            slave_config: slaveConfig,
            sensors: []
          })
        }

        for (let n = 0, len2 = this.slaveSensorData.length; n < len2; n++) {
          if (this.slaveSensorData[n].slave_name == this.addSlaveForm.name) {
            this.slaveSensorData[n].slave_protocol = this.addSlaveForm.slave_protocol;
            this.slaveSensorData[n].channel_type = this.addSlaveForm.channel;
            this.slaveSensorData[n].slave_no = this.addSlaveForm.num;
            this.slaveSensorData[n].slave_addr = this.addSlaveForm.slave_addr;
            this.slaveSensorData[n].slave_config = this.copy(slaveConfig);
            break;
          }

        }
        this.addSlaveFormVisible = false;
      },

      getTemplate() {
        var that = this;
        that.moulds = [{
          value: 0,
          label: '无'
        }];
        this.$http({
          method: 'post',
          url: 'api/template/all',
          data: {
            'version': 2
          }
        }).then(res => {
          //console.log(res.data)
          if (res && res.data.result == "success") {

            for (let i = 0; i < res.data.data.length; i++) {
              let mould = {
                value: res.data.data[i].id,
                label: res.data.data[i].template_name
              }
              that.moulds.push(mould);
            }
            that.addSlaveForm.template = that.moulds[0].value;
          }
        }).catch(error => {
          console.log(error);
        });
      },

      getSlaveInfo(row) {
        let nowChannel = "";
        this.editSlaveForm.name = row.slave_name;
        this.editSlaveForm.num = row.slave_no;
        this.editSlaveForm.slave_addr = row.slave_addr;
        this.editSlaveForm.sensors_count = row.sensors_count;
        this.editSlaveForm.channel = row.channel_type;
        this.editSlaveForm.template = 0;
        this.editProtocol = row.slave_protocol;
        for (let i = 0, len = this.slaveChannels.length; i < len; i++) {
          if (this.slaveChannels[i].value == this.editSlaveForm.channel) {
            nowChannel = this.slaveChannels[i].value;
            this.channelWord = this.slaveChannels[i].label;
            break;
          }
        }
        if (nowChannel.indexOf('485') >= 0) {
          this.protocols = this.protocols_485;
          this.shortChannel = "";
        } else if (nowChannel.indexOf('Com') == 0) {
          this.protocols = this.protocols_485;
          this.shortChannel = "Com";
        } else if (nowChannel.indexOf('232') >= 0) {
          this.protocols = this.protocols_485;
          this.shortChannel = "232_";
        } else if (nowChannel.indexOf('thernet') >= 0) {
          this.protocols = this.protocols_ethernet;
          this.shortChannel = "";
        } else if (nowChannel.indexOf('oRa') >= 0) {
          this.protocols = this.protocols_485;
          this.shortChannel = "LoRa_";
        } else if (nowChannel.indexOf('igbee') >= 0) {
          this.protocols = this.protocols_485;
          this.shortChannel = "Zig_";
        } else if (nowChannel.indexOf('ocal') >= 0) {
          this.protocols = this.protocols_local;
          this.shortChannel = "Local";
        }


        if (this.editProtocol && (this.editProtocol.indexOf('rtu_master') >= 0 || this.editProtocol.indexOf('ascii') >=
            0)) {
          this.editModbusMaster = Object.assign({}, row.slave_config);
          this.shortProtocol = 'Slave';
        } else if (this.editProtocol && (this.editProtocol.indexOf('lient') >= 0)) {
          this.editModbusClient = Object.assign({}, row.slave_config);
          this.shortProtocol = 'Server';
        } else if (this.editProtocol && this.editProtocol.indexOf('ver') >= 0) {
          this.editModbusClient = Object.assign({}, row.slave_config);
          this.shortProtocol = 'Server';
        } else if (this.editProtocol && this.editProtocol == 'modbus') {
          this.editLocalSlave = Object.assign({}, row.slave_config);
          this.shortProtocol = '';
        } else if (this.editProtocol && this.editProtocol.indexOf('pi') >= 0) {
          this.editS7_200_ppi = Object.assign({}, row.slave_config);
          this.shortProtocol = 'S7-200PLC';
        } else if (this.editProtocol && this.editProtocol.indexOf('645_1997') >= 0) {
          this.editDL_T645 = Object.assign({}, row.slave_config);
          this.shortProtocol = '645_97_';
        } else if (this.editProtocol && this.editProtocol.indexOf('645_2007') >= 0) {
          this.editDL_T645 = Object.assign({}, row.slave_config);
          this.shortProtocol = '645_07_';
        } else if (this.editProtocol && this.editProtocol.indexOf('rogram') >= 0) {
          this.editS7_200_ppi = Object.assign({}, row.slave_config);
          this.shortProtocol = 'Slave';
        } else if (this.editProtocol && this.editProtocol.indexOf('erial') >= 0) {
          this.editFx_serial_port = Object.assign({}, row.slave_config);
          this.shortProtocol = 'Slave';
        } else if (this.editProtocol && (this.editProtocol.indexOf('mart') >= 0)) {
          this.editS7_1200_1500 = Object.assign({}, row.slave_config);
          this.shortProtocol = 'S7-SmartPLC';
        } else if (this.editProtocol && (this.editProtocol.toLowerCase() == 's7_200')) {
          this.editS7_1200_1500 = Object.assign({}, row.slave_config);
          this.shortProtocol = 'S7-200PLC';
        } else if (this.editProtocol && (this.editProtocol.indexOf('1200') >= 0)) {
          this.editS7_1200_1500 = Object.assign({}, row.slave_config);
          this.shortProtocol = 'S7-1200PLC';
        } else if (this.editProtocol && (this.editProtocol.indexOf('300') >= 0)) {
          this.editS7_1200_1500 = Object.assign({}, row.slave_config);
          this.shortProtocol = 'S7-300/400PLC';
        } else if (this.editProtocol && (this.editProtocol.indexOf('1500') >= 0)) {
          this.editS7_1200_1500 = Object.assign({}, row.slave_config);
          this.shortProtocol = 'S7-1500PLC';
        }
      },

      changeEditProtocol(protocol) {
        if (this.editProtocol.indexOf('rtu_master') >= 0 || this.editProtocol.indexOf('ascii') >= 0) {
          this.shortProtocol = 'Slave';
        } else if (this.editProtocol.indexOf('lient') >= 0) {
          this.shortProtocol = 'Server';
        } else if (this.editProtocol.indexOf('ver') >= 0) {
          this.shortProtocol = 'Server';
        } else if (this.editProtocol == 'modbus') {
          this.shortProtocol = '';
        } else if (this.editProtocol.indexOf('pi') >= 0) {
          this.shortProtocol = 'S7-200PLC';
        } else if (this.editProtocol.indexOf('645_1997') >= 0) {
          this.shortProtocol = '645_97_';
        } else if (this.editProtocol.indexOf('645_2007') >= 0) {
          this.shortProtocol = '645_07_';
        } else if (this.editProtocol.indexOf('rogram') >= 0) {
          this.shortProtocol = 'Slave';
        } else if (this.editProtocol.indexOf('erial') >= 0) {
          this.shortProtocol = 'Slave';
        } else if (this.editProtocol.indexOf('mart') >= 0) {
          this.shortProtocol = 'S7-SmartPLC';
        } else if (this.editProtocol.toLowerCase() == 's7_200') {
          this.shortProtocol = 'S7-200PLC';
        } else if (this.editProtocol.indexOf('1200') >= 0) {
          this.shortProtocol = 'S7-1200PLC';
        } else if (this.editProtocol.indexOf('300') >= 0) {
          this.shortProtocol = 'S7-300/400PLC';
        } else if (this.editProtocol.indexOf('1500') >= 0) {
          this.shortProtocol = 'S7-1500PLC';
        }

        if (this.editProtocol.indexOf('s7') >= 0) {
          this.editSlaveForm.slave_addr = 2;
          this.editS7_1200_1500.server_ip = "192.168.2.1";
        } else if (this.editProtocol.indexOf('645') >= 0) {
          this.editSlaveForm.slave_addr = "000000691889";
        } else {
          this.editSlaveForm.slave_addr = 1;
        }
        if (this.channelWord.indexOf('thernet') >= 0) {
          this.editSlaveForm.num = this.shortChannel + this.shortProtocol + '1';
        } else if (this.channelWord.indexOf('ocal') >= 0) {
          this.editSlaveForm.num = this.shortChannel;
        } else if (this.editProtocol.indexOf('645') >= 0) {
          this.editSlaveForm.num = this.shortChannel + this.shortProtocol + this.editSlaveForm.slave_addr.substr(this
            .editSlaveForm.slave_addr.length - 3, 3);
        } else {
          this.editSlaveForm.num = this.shortChannel + this.shortProtocol + this.editSlaveForm.slave_addr;

        }
      },

      changeEditAddr() {
        if (this.channelWord.indexOf('thernet') >= 0) {
          this.editSlaveForm.num = this.shortChannel + this.shortProtocol + '1';
        } else if (this.channelWord.indexOf('ocal') >= 0) {
          this.editSlaveForm.num = this.shortChannel;
        } else if (this.editProtocol.indexOf('645') >= 0) {
          this.editSlaveForm.num = this.shortChannel + this.shortProtocol + this.editSlaveForm.slave_addr.substr(this
            .editSlaveForm.slave_addr.length - 3, 3);
        } else {
          this.editSlaveForm.num = this.shortChannel + this.shortProtocol + this.editSlaveForm.slave_addr;

        }
      },

      preModifySlave(row) {
        var that = this;
        this.slaveId = row.id;
        this.getChannel();
        this.getSlaveInfo(row);
        this.editSlaveFormVisible = true;

      },

      modifySlave() {
        var that = this;
        let slaveConfig = {};
        if (this.editProtocol.indexOf('rtu_master') >= 0 || this.editProtocol.indexOf('ascii') >= 0) {
          slaveConfig = Object.assign({}, this.editModbusMaster);
        } else if (this.editProtocol.indexOf('lient') >= 0) {
          slaveConfig = Object.assign({}, this.editModbusClient);
        } else if (this.editProtocol.indexOf('ver') >= 0) {
          slaveConfig = Object.assign({}, this.editModbusClient);
        } else if (this.editProtocol == 'modbus') {
          slaveConfig = Object.assign({}, this.editLocalSlave);
        } else if (this.editProtocol.indexOf('pi') >= 0 || this.editProtocol.indexOf('rogram') >= 0) {
          slaveConfig = Object.assign({}, this.editS7_200_ppi);
        } else if (this.editProtocol.indexOf('645') >= 0) {
          slaveConfig = Object.assign({}, this.editDL_T645);
        } else if (this.editProtocol.indexOf('mart') >= 0 || this.editProtocol.indexOf('1200') >= 0 || this.editProtocol
          .indexOf('300') >= 0 || this
          .editProtocol.indexOf('1500') >= 0 || this.editProtocol.toLowerCase() == 's7_200') {
          slaveConfig = Object.assign({}, this.editS7_1200_1500);
        } else if (this.editProtocol.indexOf('erial') >= 0) {
          slaveConfig = Object.assign({}, this.editFx_serial_port);
        }

        for (let i = 0, len = this.channelSlaves.length; i < len; i++) {
          if (this.channelSlaves[i].id == this.editSlaveForm.channel) {
            for (let n = 0, len2 = this.channelSlaves[i].children.length; n < len2; n++) {
              if (this.channelSlaves[i].children[n].slave_no == this.editSlaveForm.num) {
                this.channelSlaves[i].children[n].slave_name = this.editSlaveForm.name;
                this.channelSlaves[i].children[n].id = this.editSlaveForm.name;
                this.channelSlaves[i].children[n].label = this.editSlaveForm.name;
                this.channelSlaves[i].children[n].slave_addr = this.editSlaveForm.slave_addr;
                this.channelSlaves[i].children[n].slave_protocol = this.editProtocol;
                this.channelSlaves[i].children[n].slave_config = this.copy(slaveConfig);
                this.getSlaveShowInfo(this.channelSlaves[i].children[n]);
                this.$forceUpdate();
                break;

              }
            }

          }
        }
        if (this.editSlaveForm.template) {
          this.getTemplateInfo(this.editSlaveForm.template, this.editSlaveForm.name);
          for (let m = 0, len3 = this.slaveSensorData.length; m < len3; m++) {
            if (this.slaveSensorData[m].slave_no == this.editSlaveForm.num) {
              setTimeout(function() {
                //引用型数据不能使用浅拷贝，内有数组
                //that.slaveSensorData[m]=Object.assign({},that.templateSensor);
                that.slaveSensorData[m].sensors_count = that.templateSensor.sensors_count;
                that.slaveSensorData[m].sensors = that.templateSensor.sensors;
                that.$message({
                  message: '该子设备数据点已替换，你可以保存或下发！',
                  type: 'info',
                  offset: 300

                })
              }, 500)
              break;
            }
          }
        } else {
          for (let m = 0, len3 = this.slaveSensorData.length; m < len3; m++) {
            if (this.slaveSensorData[m].slave_no == this.editSlaveForm.num) {
              this.slaveSensorData[m].slave_name = this.editSlaveForm.name;
              for (let k = 0, len5 = this.slaveSensorData[m].sensors.length; k < len5; k++) {
                this.slaveSensorData[m].sensors[k].slave_name = this.editSlaveForm.name;
              }
              break;
            }
          }
        }
        setTimeout(function() {
          for (let k = 0, len4 = that.slaveSensorData.length; k < len4; k++) {
            if (that.slaveSensorData[k].slave_no == that.editSlaveForm.num) {
              that.slaveSensorData[k].slave_name = that.editSlaveForm.name;
              that.slaveSensorData[k].slave_addr = that.editSlaveForm.slave_addr;
              that.slaveSensorData[k].channel_type = that.editSlaveForm.channel;
              that.slaveSensorData[k].slave_config = that.copy(slaveConfig);
              that.slaveSensorData[k].slave_protocol = that.editProtocol;
              for (let l = 0, len5 = that.slaveSensorData[k].sensors.length; l < len5; l++) {
                that.slaveSensorData[k].sensors[l].channel_type = that.editSlaveForm.channel;
                that.slaveSensorData[k].sensors[l].slave_protocol = that.editProtocol;
              }
              //console.log(that.slaveSensorData[k]);
              break;
            }
          }

        }, 1200)
        this.editSlaveFormVisible = false;
      },

      sureDelete(id, label) {
        this.$confirm('删除后该子设备将消失,相关数据也将清除,删除后无法恢复,是否确认删除?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.handleClick(id, label);

        }).catch(() => {
          //               this.$message({
          //                   type: 'info',
          // duration:2000,
          //                   offset:300,
          //                   message: '已取消删除'
          //               });
        });
      },

      handleClick(id, label) {
        let slaveNo = '';
        for (let i = 0, len = this.channelSlaves.length; i < len; i++) {
          for (let n = 0, len2 = this.channelSlaves[i].children.length; n < len2; n++) {
            if (this.channelSlaves[i].children[n].id == id) {
              slaveNo = this.channelSlaves[i].children[n].slave_no;
              this.channelSlaves[i].children.splice(n, 1);
            }
          }
        }
        for (let n = 0, len3 = this.slaveSensorData.length; n < len3; n++) {
          if (this.slaveSensorData[n].slave_name == id) {
            this.slaveSensorData.splice(n, 1);

          }
        }
        this.removeArrayItem(this.allSlavesId, slaveNo);
        this.removeArrayItem(this.allSlaves, label);
        this.infoShow = "channel";
        this.getChannelInfo(this.channelSlaves[0])
      },

      //以下两个方法是构造删除数组的某个元素的函数；
      // Array.prototype.indexOf = function(val) {
      // for (var i = 0; i < this.length; i++) {
      // if (this[i] == val) return i;
      // }
      // return -1;
      // };

      // Array.prototype.remove = function(val) {
      // var index = this.indexOf(val);
      // if (index > -1) {
      // this.splice(index, 1);
      // }
      // };

      //删除数组某个元素简化函数
      //removeArrayItem(原数组,要删除的元素)
      removeArrayItem(arr, val) {
        let index = 0;
        for (let i = 0; i < arr.length; i++) {
          if (arr[i] == val) {
            index = i;
            arr.splice(index, 1);
            break;
          }
        }
      },



      //右侧数据点相关函数
      getSensor(sensorArr, name) {
        let sensors = sensorArr;
        //var len=sensorArr.length;
        //this.addForm.list_order=Number(sensorArr[len-1].list_order)+1;
        for (let i = 0, len = sensorArr.length; i < len; i++) {
          sensors[i] = this.getSensorOne(sensorArr[i]);
          //如果原数据没有排序字段或都为0，排序按索引号；
          sensors[i].list_order = sensorArr[i].list_order ? sensorArr[i].list_order : i + 1;
          sensors[i].slave_name = name;
        }
        return sensors;
      },

      getSensorOne(sensor) {
        let newSensor = sensor;
        if (sensor.show_type > 2) {
          newSensor.decimals = 0;
          newSensor.unit = '';
        }

        if (this.deviceData.app_scene == 1) {
          //delete newSensor.min_value;
          //delete newSensor.max_value;
          delete newSensor.mark;
        }

        if (sensor.save_type == 1) {
          newSensor.save_type = '存储';
        } else if (sensor.save_type == 2) {
          newSensor.save_type = '不存储';
        } else if (sensor.save_type == 3) {
          newSensor.save_type = '变化存储';
        }
        return newSensor;
      },

      copy(obj) {
        return Object.assign({}, obj);
        //return {...obj};//也可以用扩展运算符
      },

      showUpdate(item, index, e) {
        var that = this;
        //console.log(item.slave_protocol);
        if (item.slave_protocol.indexOf('645') < 0) {
          delete item.sign_0;
          delete item.sign_1;
          delete item.sign_2;
          delete item.sign_3;
          this.addressValueType(item.data_key);
        } else {
          this.valueTypes = this.valueTypes_T645;
        }
        //e.currentTarget.parentElement.style.backgroundColor = "#ddd";
        for (let i = 0, len = this.slaveSensorData.length; i < len; i++) {
          if (this.slaveSensorData[i].slave_name == item.slave_name) {
            for (let n = 0, len2 = this.slaveSensorData[i].sensors.length; n < len2; n++) {
              if (this.slaveSensorData[i].sensors[n].sensor_name == item.sensor_name) {
                //this.editForm = this.copy(item);
                this.editForm = this.sensorToData(item);
              }
            }

          }
        }
        this.editForm.index = index;
        this.dialogFormVisible_2 = true;
      },

      sensorToData(sensor) {
        let newSensor = this.copy(sensor);
        //console.log(sensor.show_type);
        if (sensor.show_type > 2) {
          newSensor.decimals = 0;
          newSensor.unit = '';
        }

        if (sensor.save_type == '存储') {
          newSensor.save_type = 1;
        } else if (sensor.save_type == '不存储') {
          newSensor.save_type = 2;
        } else if (sensor.save_type == '变化存储') {
          newSensor.save_type = 3;
        }

        return newSensor;
      },

      cancelUpdate() {
        var that = this;
        this.dialogFormVisible_2 = false;
        //this.editForm.visible = false;
        //this.getSensor();
      },

      changeAddType(type) {
        if (type > 2) {
          this.addForm.decimals = 0;
          this.addForm.unit = '';
          this.addForm.threshold = 1;
        } else {
          this.addForm.threshold = 0;
        }
      },

      changeAddDecimal(decimal, magnification) {
        if (this.addForm.slave_protocol.indexOf('645') >= 0) {
          var initMagn = 1;
          if (Number.isInteger(Number(magnification))) {
            initMagn = Number(magnification);
          } else {
            initMagn = Number(magnification.toString().split('.')[1]);
          }
          this.addForm.magnification = initMagn / (10 ** Number(decimal));
        }
      },

      changeEditType(type) {
        if (type > 2) {
          this.editForm.decimals = 0;
          this.editForm.unit = '';
          this.editForm.threshold = 1;
        } else {
          this.editForm.threshold = 0;
        }
      },

      changeEditDecimal(decimal, magnification) {
        if (this.editForm.slave_protocol.indexOf('645') >= 0) {
          var initMagn = 1;
          if (Number.isInteger(Number(magnification))) {
            initMagn = Number(magnification);
          } else {
            initMagn = Number(magnification.toString().split('.')[1]);
          }
          this.editForm.magnification = initMagn / (10 ** Number(decimal));
        }
      },

      changeReportAdd() {
        if (this.addForm.report_type == 1) {
          this.addForm.save_type = 2;
        }
      },
      changeReportEdit() {
        if (this.editForm.report_type == 1) {
          this.editForm.save_type = 2;
        }
      },

      chooseIcon(event) {
        var that = this;
        let iconurl = 'static/images/icon/icon' + event.target.id + '.png';
        this.addForm.icon = iconurl;
        //this.addForm.visible = false;
        //document.getElementById(this.domainIndex).src=this.baseurl+iconurl;
      },

      chooseIcon_2() {
        var that = this;
        let iconurl = 'static/images/icon/icon' + event.target.id + '.png';
        this.editForm.icon = iconurl;
        //this.editForm.visible = false;
      },
      cancelCopy() {
        this.dialogFormVisible_3 = false;
      },

      updateHappen() {
        var that = this;
        if (this.editForm.show_type > 2) {
          this.editForm.decimals = 0;
          this.editForm.unit = '';
        }

        for (let i = 0, len = this.slaveSensorData.length; i < len; i++) {
          if (this.slaveSensorData[i].slave_name == this.editForm.slave_name) {
            this.slaveSensorData[i].sensors[this.editForm.index] = this.getSensorOne(this.editForm);
          }
        }
        //this.editForm.visible = false;
        this.dialogFormVisible_2 = false;
      },

      sureDeleteSensor(item, index, e) {
        //e.currentTarget.parentElement.style.backgroundColor = "#ddd";

        this.$confirm('删除后无法恢复, 是否确认删除该数据点?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.removeDomain(item, index);
        }).catch(() => {
          //               this.$message({
          //                   type: 'info',
          // duration:2000,
          // offset:300,
          //                   message: '已取消删除'
          //               });
        });
      },

      removeDomain(item, index) {
        for (let i = 0, len = this.slaveSensorData.length; i < len; i++) {
          if (this.slaveSensorData[i].slave_name == item.slave_name) {
            this.slaveSensorData[i].sensors.splice(index, 1);
          }
        }
      },

      createT645Key() {
        //let changeName=this.addForm.sensor_name==this.addForm.data_key?false:true;
        if (this.addForm.slave_protocol.indexOf('2007') >= 0) {
          this.addForm.data_key = (this.addForm.sign_0 + this.addForm.sign_1 + this.addForm.sign_2 + this.addForm
            .sign_3).toUpperCase();
        } else {
          this.addForm.data_key = (this.addForm.sign_0 + this.addForm.sign_1).toUpperCase();
        }
        // if(!changeName){
        // 	this.addForm.sensor_name=this.addForm.data_key;
        // }
        this.addForm.sensor_name = this.addForm.data_key;
      },

      // padLeft(str, len, char) {
      //     let strlen = str.toString().length;
      //     let newStr = '';
      //     if (strlen < len) {
      //         for (let i = 0; i < len - strlen; i++) {
      //             newStr = newStr + char;
      //         }
      //         newStr = newStr + str;
      //     } else {
      //         newStr = str;
      //     }
      //     return newStr;
      // },

      //生成首个完整地址的函数
      //createFirstKey(协议，通道,数值类型,起始寻址,DB块块号)
      createFirstKey(procotol, channel, valueType, firstKey, box) {
        this.$forceUpdate();
        let char = '';
        let int = '';
        let point = '';
        let newProcotol = procotol.toLowerCase();
        if (newProcotol.indexOf('_fx_') < 0) {
          switch (channel) {
            case '0':
            case '1':
            case '3':
            case '4':
              //前缀控制
              char = channel + 'x';
              //整数部分控制
              if (Number(firstKey) >= 0 && Number(firstKey) <= 65535) {
                int = configData.padLeft(Number(firstKey) + 1, 5, '0');
              } else {
                this.$message({
                  type: 'error',
                  duration: 2000,
                  message: '起始地址超出范围',
                  center: true
                })
              }
              //小数部分控制
              if (valueType >= 50 && valueType <= 65) {
                point = '.' + configData.padLeft(valueType - 50, 2, '0');
              }
              break;
            case 'I':
            case 'Q':
              char = channel;
              //整数部分控制
              if (Number(firstKey) >= 0 && Number(firstKey) <= 9999) {
                int = firstKey;
              } else {
                this.$message({
                  type: 'error',
                  duration: 2000,
                  message: '起始地址超出范围',
                  center: true
                })
              }
              //小数部分控制
              if (valueType >= 50 && valueType <= 57) {
                point = '.' + (valueType - 50);
              }
              break;
            case 'M':
            case 'V':
              //16位数值型（不含按位）
              if ([3, 4, 13, 14].indexOf(valueType) >= 0) {
                char = channel + 'W'
                //8位数值型（不含按位）
              } else if ([1, 2, 11, 12].indexOf(valueType) >= 0) {
                char = channel + 'B'
                //32位和float数值型
              } else if ([5, 6, 9, 15, 16].indexOf(valueType) >= 0) {
                char = channel + 'D'
              } else {
                char = channel;
              }
              //整数部分控制
              if (Number(firstKey) >= 0 && Number(firstKey) <= 9999) {
                int = firstKey;
              } else {
                this.$message({
                  type: 'error',
                  duration: 2000,
                  message: '起始地址超出范围',
                  center: true
                })
              }
              //小数部分控制
              if (valueType >= 50 && valueType <= 57) {
                point = '.' + (valueType - 50);
              }
              break;
            case 'D':
              //16位数值型（不含按位）
              if ([3, 4, 13, 14].indexOf(valueType) >= 0) {
                char = 'DB' + box + '.DBW';
                //8位数值型（不含按位）
              } else if ([1, 2, 11, 12].indexOf(valueType) >= 0) {
                char = 'DB' + box + '.DBB';
                //32位和float数值型
              } else if ([5, 6, 9, 15, 16].indexOf(valueType) >= 0) {
                char = 'DB' + box + '.DBD';
              } else {
                char = 'DB' + box + '.DB';
              }
              //整数部分控制
              if (Number(firstKey) >= 0 && Number(firstKey) <= 9999) {
                int = firstKey;
              } else {
                this.$message({
                  type: 'error',
                  duration: 2000,
                  message: '起始地址超出范围',
                  center: true
                })
              }
              //小数部分控制
              if (valueType >= 50 && valueType <= 57) {
                point = '.' + (valueType - 50);
              }
              break;
            default:
              return '该数据通道不存在或尚未启用';
          }
          this.addForm.data_key = char + int + point;
        } else {
          char = channel;
          var maxFirstKey = channel == 'D' ? 99999 : 9999;
          if (Number(firstKey) >= 0 && Number(firstKey) <= maxFirstKey) {
            if (channel == 'X' || channel == 'Y') {
              //firstKey=Number(firstKey).toString(8);
              //因为个位是八进制，所以起始地址个位大于等于8时转为八进制，其他情况暂不考虑；
              let str = firstKey.toString();
              firstKey = Number(str[str.length - 1]) >= 8 ? Number(firstKey).toString(8) : Number(firstKey);
            }
            if (channel == 'D' && Number(firstKey) > 9999) {
              int = firstKey;
            } else {
              int = configData.padLeft(firstKey, 4, '0');
            }
          } else {
            this.$message({
              type: 'error',
              message: '起始地址超出范围',
              duration: 2000,
              center: true
            })
            return
          }
          this.addForm.data_key = char + int;
        }
        for (let i = 0, len = this.slaveSensorData.length; i < len; i++) {
          if (this.slaveSensorData[i].slave_name == this.addForm.slave_name) {
            let len2 = this.slaveSensorData[i].sensors.length;
            for (let n = 0; n < len2; n++) {
              if (this.slaveSensorData[i].sensors[n].data_key == this.addForm.data_key) {
                return 'repeat';
              }
            }
          }
        }
      },

      repartValueType(protocol, type) {
        var newProtocol = protocol.toLowerCase()
        if (newProtocol.indexOf('_fx_') < 0) {
          switch (type) {
            case '0':
            case '1':
              this.valueTypes = this.valueTypes_01;
              break;
            case '3':
            case '4':
              this.valueTypes = this.valueTypes_34;
              break;
            case 'I':
            case 'Q':
              this.valueTypes = this.valueTypes_IQ;
              break;
            case 'M':
            case 'V':
            case 'D':
              this.valueTypes = this.valueTypes_MV;
              break;
          }
        } else {
          //X,Y为八进制，M,D为十进制
          switch (type) {
            case 'X':
            case 'Y':
            case 'M':
              this.valueTypes = this.valueTypes_01;
              break;
            case 'D':
              this.valueTypes = this.valueTypes_Fx_D;
              break;
          }
        }
      },


      //添加数据点时，数据通道变化引起数值类型选项变化；
      chooseValueType(type,oper) {
        this.repartValueType(this.addForm.slave_protocol, type);
        if(oper=="changeChannel"){
        	if (type == "V") {
        	  this.addForm.value_type = 3; //V区默认16位有符号；
        	} else {
        	  this.addForm.value_type = this.valueTypes[0].value;
        	}
        }
        this.changeMinMax(this.addForm.value_type, this.addForm.magnification, this.addForm.threshold);
      },

      changeValueType(type) {
        if (type == 9) {
          this.addForm.decimals = this.points[2].value;
        } else {
          this.addForm.decimals = this.points[0].value;
        }
        if(type==20){  //字符串不能批量
        	this.addForm.number=1;
        	this.addForm.show_type = 9;
        	this.addForm.threshold =0;
        	this.addForm.decimals = this.points[0].value;
        	this.addForm.value_offset=0;
        	this.options= configData.optionsForString;
        }else{
        	//this.addForm.show_type = 1;
        	this.changeDataChannel(this.addForm.data_channel,'changeValue');
        }
        this.createFirstKey(this.addForm.slave_protocol, this.addForm.data_channel, type, this.addForm.first_key, this
          .addForm.boxNum);
        if (!this.changeName) {
           //如果把下面这句放在了createFirstKey里面，默认就变成了强制；
           this.addForm.sensor_name = this.addForm.data_key;
        }
        this.changeMinMax(type, this.addForm.magnification, this.addForm.threshold);
      },

      changeMinMax(valueType, magnification, threshold) {
        //if(this.deviceData.app_scene==2){
        this.addForm.min_value = configData.defaultMinMax(valueType, magnification, threshold).min;
        this.addForm.max_value = configData.defaultMinMax(valueType, magnification, threshold).max;
        //};
      },

      changeEditMinMax(valueType, magnification, threshold) {
        //if(this.deviceData.app_scene==2){
        this.editForm.min_value = configData.defaultMinMax(valueType, magnification, threshold).min;
        this.editForm.max_value = configData.defaultMinMax(valueType, magnification, threshold).max;
        //};
      },

      //编辑数据点时，根据地址对应数值类型选项；
      addressValueType(address) {
        let type = address[0];
        this.repartValueType(this.slaveInfo.slave_protocol, type);
      },

      //数据通道变化引起首地址变化；
      changeDataChannel(dataChannel,oper) {
        this.options = configData.options;
        this.chooseValueType(dataChannel,oper);
        if (['M', '0', 'Y', 'Q'].indexOf(dataChannel) >= 0) {
          this.addForm.show_type = this.options[3].value;
          this.addForm.threshold = 1;
          this.addForm.decimals = this.points[0].value;
        } else if (dataChannel == '0') {
          this.addForm.decimals = this.points[0].value;
          this.addForm.show_type = this.options[0].value;
          this.addForm.threshold = 1;
        } else if (dataChannel == '1') {
          this.addForm.decimals = this.points[0].value;
          this.addForm.show_type = this.options[4].value;
          this.addForm.threshold = 1;
        } else if (dataChannel == 'X' || dataChannel == 'I') {
          //三菱协议X区只有只读类型
          this.options = configData.optionsOnlyRead;
          this.addForm.show_type = this.options[2].value;
          this.addForm.threshold = 1;
          this.addForm.decimals = this.points[0].value;
        } else {
          this.addForm.show_type = this.options[0].value;
          this.addForm.threshold = 0;
        }
        this.$forceUpdate();
        this.createFirstKey(this.addForm.slave_protocol, dataChannel, this.addForm.value_type, this.addForm.first_key,
          this.addForm.boxNum);
      },

      addSensors(item) {
        var that = this;
        this.addForm.boxNum = 1; //默认DB块号
        this.showNameAddr = false;
        this.addForm.first_key = 0;
        this.addForm.decimals = this.points[0].value;
        this.addForm.magnification = 1;
        this.addForm.sensor_name = '';
        this.addForm.data_key = '';
        this.addForm.value_key = '';
        this.addForm.sensor_total = 1; //新增数量
        this.addForm.slave_name = item.slave_name;
        this.addForm.slave_protocol = item.slave_protocol;
        this.addForm.channel_type = item.channel_type;
        if (this.deviceData.app_scene == 1) {
          //delete this.addForm.min_value;
          //delete this.addForm.max_value;
          delete this.addForm.mark;
        }
        if (item.slave_protocol.indexOf('odbus') >= 0) {
          this.dataChannels = this.addSensor_modbus;
          //this.addForm.data_key="0x00001";

        } else if (item.slave_protocol.indexOf('_200') >= 0) {
          this.dataChannels = this.addSensor_s7200;
          //this.addForm.data_key="I0.0";

        } else if ((item.slave_protocol.indexOf('_1200') >= 0) || (item.slave_protocol.indexOf('_1500') >= 0) || (item
            .slave_protocol.indexOf('300') >= 0)) {
          this.dataChannels = this.addSensor_1200_1500;
          //this.addForm.data_key="I0.0";
        } else if (item.slave_protocol.indexOf('_fx_') >= 0) {
          this.dataChannels = this.addSensor_mitsubishi_fx;
        }


        if (item.slave_protocol.indexOf('1997') >= 0) {
          this.addForm.sign_0 = "00";
          this.addForm.sign_1 = "00";
          this.addForm.data_key = "0000";
        } else if (item.slave_protocol.indexOf('2007') >= 0) {
          this.addForm.sign_0 = "00";
          this.addForm.sign_1 = "00";
          this.addForm.sign_2 = "00";
          this.addForm.sign_3 = "00";
          this.addForm.data_key = "00000000";
        } else {
          delete this.addForm.sign_0;
          delete this.addForm.sign_1;
          delete this.addForm.sign_2;
          delete this.addForm.sign_3;
        }

        //this.addForm.data_channel = that.dataChannels[0].value;
        //modbus系列协议默认为4区(王总)
        if (item.slave_protocol.indexOf('645') <= 0) {
          if (item.slave_protocol.indexOf('odbus') >= 0) {
            this.addForm.data_channel = this.dataChannels[3].value;
          } else {
            this.addForm.data_channel = this.dataChannels[0].value;
          }
          this.options = configData.options;
          this.chooseValueType(this.addForm.data_channel[0],'changeChannel');
          if (['M', 'V', '0', 'Y'].indexOf(that.addForm.data_channel) >= 0) {
            this.addForm.show_type = this.options[3].value;
            this.addForm.threshold = 1;
          } else if (this.addForm.data_channel == 'X' || this.addForm.data_channel == 'I') {
            //三菱协议X区只有只读类型
            this.options = configData.optionsOnlyRead;
            this.addForm.show_type = this.options[2].value;
            this.addForm.threshold = 1;
          } else {
            this.addForm.show_type = this.options[0].value;
            this.addForm.threshold = 0;
          }
          this.createFirstKey(this.addForm.slave_protocol, this.addForm.data_channel, this.addForm.value_type, this
            .addForm.first_key, this.addForm.boxNum)
        } else {
          this.addForm.show_type = this.options[0].value;
          this.addForm.value_type = this.valueTypes_T645[0].value;
          this.addForm.threshold = 0;
          this.addForm.sensor_name = this.addForm.data_key;
        }
        this.changeMinMax(this.addForm.value_type, this.addForm.magnification, this.addForm.threshold);
        this.$forceUpdate();
        let max = item.sensors_count || 1;
        for (let i = 0, len = this.slaveSensorData.length; i < len; i++) {
          if (this.slaveSensorData[i].slave_name == item.slave_name) {
            let len2 = this.slaveSensorData[i].sensors.length;
            for (let n = 0; n < len2; n++) {
              if (Number(this.slaveSensorData[i].sensors[n].list_order) || Number(this.slaveSensorData[i].sensors[n]
                  .list_order) == 0) {
                max = max < Number(this.slaveSensorData[i].sensors[n].list_order) ? Number(this.slaveSensorData[i]
                  .sensors[n].list_order) : max;
              }
            }
          }
        }

        this.addForm.list_order = max + 1;
        //this.$forceUpdate();
        this.dialogFormVisible = true;

      },

      //排序有字母的累加算法；
      upListOrder(order, n) {
        let orderStr = order.toString();
        return orderStr.split(orderStr.replace(/[^0-9]/ig, "")).join('') + (
          Number(orderStr.replace(/[^0-9]/ig, "")) + n);
      },

      //16制判断函数
      is16Fix(str, name) {
        var reg = /^[0-9A-Fa-f]{2}$/;
        if (str) {
          if (!reg.test(str)) {
            this.$message({
              message: '标识' + name + '格式错误,请重新输入!',
              type: 'error'
            })
            return false;
          } else {
            return true;
          }
        } else {
          this.$message({
            message: '标识' + name + '不能为空,请输入!',
            type: 'error'
          })
          return false;
        }
      },

      //名称有数字和非数字混杂(包括纯数字和纯非数字)的复制
      copyName(str, n) {
        // if(Number(str)){
        // 	//纯数字直接加1就可以了
        // 	return Number(str)+n;
        // }
        let strArr = str.split('');
        //非数字正则表达式；
        let reg = /\D/i;
        //var reg_2 = new RegExp("[\\u4E00-\\u9FFF]+","g");//中文正则
        let index = 0;
        //判断最后一个非数字字符的位置并记录,判断是否为0是为了键名的复制
        for (let m = 0; m < strArr.length; m++) {
          if (reg.test(strArr[m])) {
            index = m;
          }
        }
        //console.log(index);
        //不包含停止位，所以要加1
        return str.substr(0, index + 1) + (Number(str.substr(index + 1)) + n);

      },

      addHappen(name) {
        var that = this;
        if (this.addForm.slave_protocol.indexOf('2007') >= 0) {
          if (!this.is16Fix(this.addForm.sign_0, 'DI0') || !this.is16Fix(this.addForm.sign_1, 'DI1') || !this.is16Fix(
              this.addForm.sign_2, 'DI2') || !this.is16Fix(this.addForm.sign_3, 'DI3')) {
            return false;
          }
        } else if (this.addForm.slave_protocol.indexOf('1997') >= 0) {
          if (!this.is16Fix(this.addForm.sign_0, 'DI0') || !this.is16Fix(this.addForm.sign_1, 'DI1')) {
            return false;
          }
        }
        if (this.addForm.sensor_total > 100) {
          this.$message({
            type: 'error',
            offset: 300,
            message: '单次添加数量不得超过100个，请重设！',
            center: true
          })
          return false;
        }
        let oneSen = this.copy(this.addForm);
        let oneSensor = this.getSensorOne(oneSen);
        if (this.createFirstKey(this.addForm.slave_protocol, this.addForm.data_channel, this.addForm.value_type, this
            .addForm.first_key, this.addForm.boxNum) == "repeat") {
          this.$message({
            type: 'error',
            offset: 300,
            message: '此起始寻址将会使地址与现有数据点产生重复，请重设！',
            center: true
          })
          return false;
        }
        let addrAndKeys = configData.createDataKey(this.addForm.data_key, this.addForm.value_type, this.addForm
          .sensor_total, true);
        addrAndKeys.forEach(function(item) {
          that.getSensorOne(item);
        });
        //console.log(addrAndKeys);
        for (let i = 0, len = this.slaveSensorData.length; i < len; i++) {
          if (this.slaveSensorData[i].slave_name == name) {
            for (let n = 0; n < this.addForm.sensor_total; n++) {
              this.slaveSensorData[i].sensors.push({
                //key: new Date().getTime(),
                // sensor_name: oneSensor.sensor_name.split(oneSensor.sensor_name.replace(/[^0-9]/ig, "")).join('') + (
                // 	Number(oneSensor.sensor_name.replace(/[^0-9]/ig, "")) + n+1),
                sensor_name: addrAndKeys[n].data_key,
                data_key: addrAndKeys[n].data_key,
                value_key: that.copyName(oneSensor.value_key, n + 1),
                list_order: Number(oneSensor.list_order) ? Number(oneSensor.list_order) + n : that.upListOrder(
                  oneSensor.list_order, n),
                unit: oneSensor.unit,
                decimals: oneSensor.decimals,
                icon: oneSensor.icon,
                //ext_vars:that.copyitem.ext_vars,
                report_type: oneSensor.report_type,
                magnification: oneSensor.magnification,
                value_offset: oneSensor.value_offset,
                threshold: oneSensor.threshold,
                //standard_max:oneSensor.standard_max,
                //standard_min:oneSensor.standard_min,
                min_value: oneSensor.min_value,
                max_value: oneSensor.max_value,
                mark: oneSensor.mark,
                slave_name: oneSensor.slave_name,
                slave_protocol: oneSensor.slave_protocol,
                channel_type: oneSensor.channel_type,
                show_type: oneSensor.show_type,
                value_type: addrAndKeys[n].value_type,
                //read_write: that.copyitem.read_write,
                save_type: oneSensor.save_type
              });
            }
          }
        }
        //this.addForm.visible = false;
        this.dialogFormVisible = false;

      },

      cancelAdd() {
        this.dialogFormVisible = false;
        //this.addForm.visible = false;
      },

      slaveInfoToData(data) {
        let slaveInfo = this.copy(data);
        slaveInfo.slave_config = this.copy(data.slave_config);
        switch (data.slave_config.write16_cmd) {
          case '0x06':
            slaveInfo.slave_config.write16_cmd = 0;
            break;
          case '0x10':
            slaveInfo.slave_config.write16_cmd = 1;
            break;
        }
        switch (data.slave_config.int16_order) {
          case 'AB':
            slaveInfo.slave_config.int16_order = 0;
            break;
          case 'BA':
            slaveInfo.slave_config.int16_order = 1;
            break;
        }
        switch (data.slave_config.crc_mode) {
          case 'LH':
            slaveInfo.slave_config.crc_mode = 0;
            break;
          case 'HL':
            slaveInfo.slave_config.crc_mode = 1;
            break;
        }
        switch (data.slave_config.int32_order) {
          case 'ABCD':
            slaveInfo.slave_config.int32_order = 0;
            break;
          case 'CDAB':
            slaveInfo.slave_config.int32_order = 1;
            break;
          case 'BADC':
            slaveInfo.slave_config.int32_order = 2;
            break;
          case 'DCBA':
            slaveInfo.slave_config.int32_order = 3;
            break;
        }
        switch (data.slave_config.float_order) {
          case 'ABCD':
            slaveInfo.slave_config.float_order = 0;
            break;
          case 'CDAB':
            slaveInfo.slave_config.float_order = 1;
            break;
          case 'BADC':
            slaveInfo.slave_config.float_order = 2;
            break;
          case 'DCBA':
            slaveInfo.slave_config.float_order = 3;
            break;
        }
        switch (data.slave_config.int64_order) {
          case 'ABCDEFGH':
            slaveInfo.slave_config.int64_order = 0;
            break;
          case 'GHEFCDAB':
            slaveInfo.slave_config.int64_order = 1;
            break;
          case 'BADCFEHG':
            slaveInfo.slave_config.int64_order = 2;
            break;
          case 'KGFEDCBA':
            slaveInfo.slave_config.int64_order = 3;
            break;
        }
        switch (data.slave_config.double_order) {
          case 'ABCDEFGH':
            slaveInfo.slave_config.double_order = 0;
            break;
          case 'GHEFCDAB':
            slaveInfo.slave_config.double_order = 1;
            break;
          case 'BADCFEHG':
            slaveInfo.slave_config.double_order = 2;
            break;
          case 'KGFEDCBA':
            slaveInfo.slave_config.double_order = 3;
            break;
        }
        return slaveInfo;
      },

      saveSet(type) {
        this.operType = type;
        localStorage.setItem("operType", type);
        if (type == 'send') {
          this.$confirm('保存并下发成功后将覆盖设备现有配置且无法还原, 是否确认该操作?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.sureSaveSet(type);
          }).catch(() => {
            //                  this.$message({
            //                      type: 'info',
            // duration:2000,
            // offset:300,
            //                      message: '已取消保存和下发'
            //                  });
          });
        } else {
          this.sureSaveSet(type);
        }
      },

      //保存并下发配置函数
      sureSaveSet(type) {
        var that = this;
        this.canSet = true;
        this.sendLoading = true;
        let allSensors = [];
        let channelSlaves = this.channelSlaves;
        for (let i = 0, len = this.slaveSensorData.length; i < len; i++) {
          for (let n = 0, len2 = this.slaveSensorData[i].sensors.length; n < len2; n++) {
            let oneSensor = this.copy(this.slaveSensorData[i].sensors[n]);
            // if(this.deviceData.app_scene==3){
            // 	delete this.slaveSensorData[i].sensors[n].value_key;
            // }
            oneSensor = this.sensorToData(oneSensor);
            allSensors.push(oneSensor);
          }
        }
        for (let k = 0, len3 = this.channelSlaves.length; k < len3; k++) {
          channelSlaves[k] = this.channelSlaves[k];
          channelSlaves[k].children = this.channelSlaves[k].children;
          channelSlaves[k].channel_config = this.channelSlaves[k].channel_config;
          if (this.channelSlaves[k].label.indexOf('thernet') == -1 && this.channelSlaves[k].label.indexOf(
              'ocal') == -1) {
            if (this.channelSlaves[k].channel_config.parity == 'None') {
              channelSlaves[k].channel_config.parity = 0;
            } else if (this.channelSlaves[k].channel_config.parity == 'Odd') {
              channelSlaves[k].channel_config.parity = 1;
            } else if (this.channelSlaves[k].channel_config.parity == 'Even') {
              channelSlaves[k].channel_config.parity = 2;
            }
          }
          for (let l = 0, len4 = this.channelSlaves[k].children.length; l < len4; l++) {
            channelSlaves[k].children[l] = this.slaveInfoToData(this.channelSlaves[k].children[l]);
            //channelSlaves[k].children[l].slave_config=this.channelSlaves[k].children[l].slave_config;
          }
        }

        this.$http({
          method: 'post',
          url: type == 'save' ? 'api/equip/saveConfig' : 'api/equip/saveRemoteConfig',
          data: {
            "id": this.deviceData.id,
            "tree": this.channelSlaves,
            "vars": allSensors
          }
        }).then(res => {
          if (res && res.data.result == "success") {
            this.sendLoading = false;
            this.$message({
              message: type == 'save' ? '恭喜,保存配置成功!' : '恭喜,保存并下发配置已经成功！',
              type: 'success',
              duration: 2000,
              offset: 300,
              center: true
            });
            setTimeout(function() {
              that.$router.push({
                name: 'slave',
                path: 'slave',
                component: 'slave'
              });
            }, 2000)
            // if (type != 'save') {
            //     setTimeout(function() {
            //         that.canSet = false;
            //     }, 60000);

            // }
          } else {
            this.sendLoading = false;
            this.canSet = false;
          }
        }).catch(error => {
          this.sendLoading = false;
          this.canSet = false;
          console.log(error);
        });

      },

      sendTemplate() {
        this.dialogFormVisible_4 = true;
        this.copyTem = {
          template_name: '',
          remark: ''
        };
      },


      getTemplateInfo(id, name) {
        var that = this;
        this.templateSensor = {
          slave_name: name,
          sensors_count: 0,
          sensors: []
        };
        this.$http({
          method: 'post',
          url: 'api/template/info',
          data: {
            "id": id
          }
        }).then(res => {
          if (res && res.data.result == "success") {
            this.templateSensor.sensors = res.data.data.sensors;
            this.templateSensor.sensors_count = res.data.data.sensors.length;
            for (let i = 0, len = res.data.data.sensors.length; i < len; i++) {
              this.templateSensor.sensors[i] = this.getSensorOne(res.data.data.sensors[i]);
              this.templateSensor.sensors[i].slave_name = name;
            }

          }

        }).catch(error => {
          console.log(error);

        });
      }
    },
    beforeDestroy() {
      this.$message.closeAll();
    },

    destroyed() {

    }
  }
</script>

<style scoped>
  @media all and (max-width:2560px) {
    .midLine {
      height: 23.9rem !important;
      /*21.4rem*/
    }

    .channel {
      height: 24rem !important;
      /*21.4rem*/
    }

    .slave {
      height: 24rem !important;
      /*21.4rem*/
    }

    .mar_5 {
      margin-left: -0.2rem !important;
    }
  }

  @media all and (max-width:1920px) {
    .midLine {
      height: 16.8rem !important;
      /*14.6rem*/
    }

    .channel {
      height: 17rem !important;
      /*14.6rem*/
    }

    .slave {
      height: 17rem !important;
      /*14.6rem*/
    }

    .mar_5 {
      margin-left: -0.7rem !important;
    }
  }

  @media all and (max-width:1600px) {
    .mar_5 {
      margin-left: -1.2rem !important;
    }

    .slaveInfo {
      height: 4.2rem !important;
    }

    .btn_1600 {
      height: 0.5rem !important;
      line-height: 0.5rem !important;
      padding: 0 6px !important;
      transform: translateY(-0.22rem) !important;
    }

    .custom-tree-node {
      font-size: 0.25rem !important;
    }
  }

  @media all and (max-width:1366px) {
    .slaveInfo {
      margin-top: 2px !important;
      height: 3.8rem !important;
    }

    .for_1366 {
      margin-top: -0.6rem !important;
    }

    .btnBox {
      height: 42px !important;
      line-height: 42px !important;
    }

    .channelHead {
      min-height: 1.6rem !important;
      max-height: 3.2rem !important;
      margin-bottom: 0 !important;
    }

    .mar_5 {
      margin-left: -1.5rem !important;
    }

    .pari {
      margin-top: 1rem !important;
    }

    .slaveInpu_2 {
      width: 3.6rem !important;
    }

    .addform {
      margin-top: -0.3rem !important;
    }

    .slaveInfo /deep/ .el-input__inner,
    .slaveInfo_3 /deep/ .el-input__inner,
    .argmentBox /deep/ .el-input__inner,
    .inpu /deep/ .el-input__inner,
    .inpu_2 /deep/ .el-input__inner,
    .inpu_3 /deep/ .el-input__inner,
    .inpu_4 /deep/ .el-input__inner,
    .inpu_5 /deep/ .el-input__inner {
      height: 0.8rem !important;
      line-height: 0.8rem !important;
      padding: 0 2px;
      padding-right: 0 !important;
    }
  }

  .channel {
    float: left;
    width: 15%;
    height: 17rem;
    position: relative;
    z-index: 1;
    transition: all 1s linear;
    /*14.6rem*/
    /* border:1px solid red; */
    /* padding:0.2rem; */
  }

  .channelBack {
    display: inline-block;
    position: absolute;
    width: 0.5rem;
    height: 0.5rem;
    font-size: 0.4rem;
    padding-top: 1px;
    border-radius: 50%;
    color: #fff;
    right: 0;
    top: 0.1rem;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 3;
  }

  .channelHead {
    text-align: left;
    min-height: 1.6rem;
    max-height: 3.2rem;
    line-height: 0.8rem;
    margin-bottom: 0.3rem;
    padding-bottom: 0.2rem;
    border-bottom: 1px dashed #ccc;
  }

  .slave {
    float: right;
    width: 84%;
    height: 17rem;
    overflow: auto;
    position: relative;
    z-index: 1;
    transition: all 1s linear;
    /*14.6rem*/
    /* border:1px solid red; */
  }

  .channelShow {
    display: inline-block;
    position: absolute;
    width: 0.5rem;
    height: 0.5rem;
    font-size: 0.4rem;
    padding-top: 1px;
    border-radius: 50%;
    color: #fff;
    left: 0;
    top: 0.1rem;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 3;
  }

  /* 表格 */

  .container_table {
    width: 99.4%;
    margin-top: 0.2rem;
  }

  .dlog {
    box-sizing: border-box;
    padding: 0 !important;
    position: relative;
  }

  .inpu {
    vertical-align: middle;
    width: 5rem;
  }

  .slaveInpu_2 {
    width: 2.6rem;
  }

  .slaveInpu_2 /deep/ .el-input__inner {
    padding-left: 4px;
  }

  .tip {
    display: block;
    width: 100%;
    text-align: center;
    color: red;
    font-size: 0.25rem;
    margin-top: 0.2rem;
  }

  .tip_1 {
    color: #FF5722;
    width: 2.5rem;
    font-size: 0.25rem;
    margin-top: 0.1rem;
    line-height: 0.3rem;
    overflow: visible;
    /* margin-bottom:0rem; */
  }

  .tip_2 {
    float: left;
    width: auto;
    color: red;
    font-size: 0.35rem;
    font-weight: 550;
    margin-left: 0.4rem;
    vertical-align: middle;
  }

  .choice {
    display: inline-block;
    font-size: 0.3rem;
    text-indent: 0.3rem;
  }

  .add {
    font-size: 0.3rem;
    color: #409Eff;
    border: 1px solid #409Eff;
  }

  .infobox {
    width: 100%;
    height: auto;
    border-top: 1px solid #ccc;
    margin-top: 0.2rem;
  }

  .midLine {
    display: inline-block;
    height: 16.8rem;
    /*14.6rem*/
    width: 1px;
    margin: 0;
    background-color: #ccc;
  }

  .slaveInfo,
  .slaveInfo_3 {
    width: 100%;
    height: 3.8rem;
    margin-top: 0.3rem;
    border-bottom: 1px dashed #ccc;
    position: relative;
  }

  .slaveInfo_3 {
    height: 0.8rem;
    line-height: 0.8rem;
    margin-top: 0;
    /* display:flex;
		justify-content:space-around; */
  }

  .slaveInfo /deep/ .el-input__inner,
  .slaveInfo_3 /deep/ .el-input__inner,
  .argmentBox /deep/ .el-input__inner,
  .inpu /deep/ .el-input__inner,
  .inpu_2 /deep/ .el-input__inner,
  .inpu_3 /deep/ .el-input__inner,
  .inpu_4 /deep/ .el-input__inner,
  .inpu_5 /deep/ .el-input__inner {
    padding: 0 4px;
    padding-right: 0 !important;
  }

  .argmentBox {
    width: 100%;
    margin-top: 0.3rem;
    height: auto;
    /* border: 1px dashed #ccc; */
    position: relative;
    padding-bottom: 0.1rem;
  }

  .addform {
    text-align: left;
    /* padding-left: 80px; */
    height: 0.8rem;
    line-height: 0.8rem;
    margin-top: 0.3rem;
  }

  .formline_1 {
    height: 0.6rem;
    line-height: 0.6rem;
  }

  .sendSet {
    float: right;
    vertical-align: bottom;
  }

  .custom-tree-node {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    padding-right: 4px;
  }

  /* 数据点相关 */

  @media all and (max-width:2560px) {
    #sensorOne {
      width: 80% !important;
    }

    #sensorTwo {
      width: 80% !important;
    }
  }

  @media all and (max-width:1920px) {
    #sensorOne {
      width: 100% !important;
    }

    #sensorTwo {
      width: 95% !important;
    }
  }

  @media all and (max-width:1600px) {
    .addSensor {
      margin-top: 0.2rem !important;
    }

    #sensorOne {
      width: 100% !important;
    }

    #sensorTwo {
      width: 94% !important;
    }

    .firstItem {
      margin-top: -0.8rem !important;
      margin-bottom: 0 !important;
    }

    /* .oneSensor {
            height: 0.9rem !important;
            line-height: 0.9rem !important;
        } */
    .block {
      margin-left: -0.4rem !important;
    }

    .inpu_3 {
      width: 4.5rem !important;
    }

    .triVal {
      width: 2rem !important;
    }

    .btnBox {
      width: 37% !important;
    }

  }

  .firstItem {
    width: 100%;
    margin-bottom: 0.1rem;
    margin-top: -0.3rem;
    text-align: center;
  }

  .formline_2 {
    width: 45%;
    display: inline-block;
    margin: 0 auto;
    height: 1rem;
    line-height: 1rem;
  }

  .inpu {
    display: inline-block;
    width: 5.5rem;
    font-size: 0.25rem;
  }

  .inpu_2,
  .inpu_4 {
    display: inline-block;
    width: 2.4rem;
    font-size: 0.25rem;
    vertical-align: top;
    border: 1px solid #ccc;
    border-radius: 5px;
    height: 0.6rem;
    margin-left: -0.15rem;
    line-height: 0.6rem;
    text-align: center;
    margin-top: 0.1rem;
  }

  .inpu_4 {
    width: 4rem;
    border: 0 !important;
    font-size: 0.35rem;
  }

  .inpu_3,
  .inpu_5 {
    display: inline-block;
    width: 4rem;
    height: 0.6rem;
    line-height: 0.6rem;
    vertical-align: middle;
    margin-left: -0.1rem;
    overflow: visible;
    font-size: 0.25rem;
  }

  .inpu_5 {
    width: 1.4rem;
  }

  .triVal {
    width: 1.65rem;
    /*2rem*/
  }

  .triVal /deep/ .el-input__inner {
    padding: 0 4px;
  }

  .sensorBox {
    width: 100%;
    height: auto;
    /* overflow: auto; */
    padding: 0;
    text-align: left;
    /* padding-left: 0.6rem; */
    /* border:1px solid red; */
  }

  #sensorOne {
    width: 100%;
    height: auto;
    margin-top: 0.1rem;
    /* border:1px solid red; */
  }

  .oneSensor,
  .sensorHead {
    height: 0.8rem;
    line-height: 0.8rem;
    /* border:1px solid red; */
    padding-left: 0.2rem;
  }

  .oneSensor {
    height: 0.7rem;
    line-height: 0.7rem;
  }

  .oneSensor:hover {
    /*background-color:#f0f0f0;*/
  }

  .sensorHead {
    width: auto;
    border-bottom: 1px solid #ccc;
    margin-bottom: 0.1rem;
  }

  .thumb {
    width: 1rem;
    height: 1rem;
    vertical-align: middle;
  }

  .iconbtn {
    width: 1rem;
    height: 1rem;
    vertical-align: middle;
    padding: 0;
    border: none;
  }

  .btnBox {
    width: 32%;
    font-size: 0.3rem;
    /* padding-left:0.6rem; */
    text-align: left;
    height: 50px;
    line-height: 50px;
    border: 1px solid deepskyblue;
    border-bottom: none;
    margin-top: 0.2rem;
    /* background-color:#bbb; */
    background-color: rgba(0, 0, 0, 0.5);
    padding: 0 0.2rem;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
  }

  .slavePoint {
    display: inline-block;
    background-color: deepskyblue;
    width: 0.2rem;
    height: 0.2rem;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 0.1rem;
    margin-top: -2px;
  }

  .channel_sign {
    color: #111111 !important;
    border-bottom: 1px dashed #ccc;
  }

  .toTop,
  .toBottom {
    display: block;
    width: 0.7rem;
    height: 0.7rem;
    line-height: 0.6rem;
    text-align: center;
    position: fixed;
    bottom: 0.3rem;
    border-radius: 50%;
    right: 0.8rem;
    z-index: 10;
    background-color: rgba(0, 0, 0, 0.3);
  }

  .toBottom {
    position: absolute;
    top: 0.2rem;
    right: 0.5rem;
    line-height: 0.5rem;
  }

  .addSensor {
    float: right;
    margin-top: 0.22rem;
    background-color: transparent;
    border: 1px solid deepskyblue;
    color: #fff;
    padding-left: 0.2rem !important;
    padding-right: 0.2rem !important;
  }

  .addSensor:hover {
    border: 1px solid deepskyblue;
    background-color: rgba(0, 0, 0, 0.5) !important;
    color: deepskyblue;
  }

  .leftAddBox {
    width: 30%;
    float: left;
    margin-top: 0.2rem;
    min-height: 6rem;
    border: 1px solid red;
  }

  .rightAddBox {
    width: 69%;
    float: right;
    margin-top: 0.2rem;
    height: auto;
    border: 1px solid red;
  }

  .equipArg>>>.el-form-item__label {
    color: deepskyblue !important;
  }

  .isTrigger {
    position: absolute;
    right: 1px;
    top: 1px;
    color: deepskyblue;
    font-size: 0.2rem;
  }

  .dial>>>.el-dialog__header {
    position: relative;
    z-index: 99;
    width: 90%;
    height: 0.8rem;
    background-color: transparent !important;
  }

  .dial>>>.el-dialog__body {
    /*曲线对话框的背景色*/
    padding: 10px;
    line-height: 1rem;
  }

  /* .oneSensor:nth-child(even){
		background-color: #bbb;
	} */

  .infocontent {
    line-height: 0.42rem;
  }

  .infocontent h4 {
    font-weight: 700;
    color: #111;
    margin-top: 0.3rem;
  }
</style>
